MIDP: Get or track the currently focused Item - java

I'm adding in some functionality to a MIDP-based app which requires me to track whether or not an Item has focus. I'm only really concerned with field-style Items and need to determine when the user has finished inputting data into the Item.
I'm aware that CustomItem has the traverse() callback, but I can't find anything similar for classes like DateField, TextField and ChoiceGroup.
I'm also aware of Display.setCurrentItem() but for some strange reason there doesn't seem to be a Display.getCurrentItem() method.
Implementing all the controls as CustomItems isn't really an option as it's a pre-existing app and there are quite a lot of controls to deal with. I can't believe that nobody has run into this issue before, but I've searched on here and google to no avail. Hopefully I'm just missing something obvious in the API, but if there isn't a definite answer then creative solutions are welcome!

In MIDP 2 lcdui API, the only field-style Items are, well, interactive subclasses of Item: TextField, DateField, Gauge.
For above items the closest match to what you are asking about seem to be provided by ItemStateListener (take a look at API javadocs here if you're interested).
...used by applications which need to receive events that indicate changes in the internal state of the interactive items...For implementations that have the concept of an input focus, the listener should be called no later than when the focus moves away from an item whose state has been changed.
If you plan to use this API, carefully check the docs to verify that it indeed gives you what you want - there are some subtle limitations there. If it turns out that you need greater control than that, your options are either to use low level UI (Canvas, events) or 3rd party library like LWUIT, J2ME Polish...

Related

JavaFX - Sequential Transition modify at runtime

I have been exploring the Sequential Transition from JavaFX, and it seems a perfect fit for what I need. So, I am working on a JavaFX desktop application that essentially shows some pictures, text, and plays some video and audio files. Now, since some of those items are presented sequentially, I have decided to use the sequential transition. Now, I just run into a problem that I have tried to address but it does not seem to work as expected. Let's imagine that the sequence in which those items are presented is predefined in a Map. When those items are presented to the user, he/she needs to provide an answer, and if that is correct you can think that the item can be categorized as Done. However, in some of the cases I need that the user repeats some of the items for learning purposes. And that has to be done 'on-the-fly' since I have another window in which someone else decides which items must be repeated. As you can see, this requires some modification of the sequential transition at runtime. Is there any suggestions on how to address this challenge?
Thanks,
As the documentation for SequentialTransition states:
It is not possible to change the children of a running SequentialTransition. If the children are changed for a running SequentialTransition, the animation has to be stopped and started again to pick up the new value.

Disable Materialize Framework "Responsiveness"

I am attempting to use the materialize framework. I am very much liking the features it provides but I don't really care too much about making everything "responsive" right now. I would like to make things somewhat "static", meaning when I resize the browser, everything stays the same size (and user can scroll around in a smaller window to find what they want). I plan to later work on the full "responsiveness" to support things like mobile, window resizing, etc. Below shows whats currently happening. I downloaded the whole framework so I'm free to alter the .css that comes along with it, but I'm not really a .css expert so not really sure where to begin.
Full Screen
Resized Screen - obviously cannot stay like this forever
Any help is much appreciated.
First to answer your question directly: I assume you are using the Materialize grid? Meaning you have divs with class names like "col l6"? To have non responsive elements you should not use any materialize column class names. It will then just be regular old HTML and CSS that you define. Materialize only applies its CSS to elements that use its classnames.
Now for a recommendation: This will probably break some of the features of Materialize. Or at the very least, it will look gross and you will have to add padding/margins everywhere manually. Then if you want to go back and enable mobile responsiveness, you will have to manually remove all of that. You will also have to use old fashioned CSS rules to determine you element sizing. Every element will need a height and width rule applied to it. It is a lot harder to add mobile responsive classes later. It will save you a lot of time if you just do it now. It's quite easy in Materialize once you get the hang of it.
One of the main reasons that Materialize and Bootstrap and the like are used, is to make mobile responsive websites easy. It really is an essential skill to learn for web development these days.

Using Java Swing, how could one implement a search box that has options similar to web browsers or iTunes?

Didn't know quite how to title this question, so suggested edits are welcome.
Right now, I have a fairly simple pair of JComboBoxes for searching row & column headers in a heatmap display. It's been augmented with the ability to allow wildcards. Here's what it looks like:
It works well enough, but a new requirement for the next version is to consolidate the pair of search boxes into 1 search box plus a few other enhancements. Basically, what we'd like to do is enter a search term and have the resulting dropdown have 2 sections: 1 for options and another for the matching results. The desired options would be things like this:
Search rows/columns checkboxes
song/artist/genre checkboxes (to use the iTunes analogy) or google/bing (to use the browser analogy)
Search within previous search results: like have a previous search term with an 'x' next to it to clear it. It would act like a filter.
The thing about this is, the desire to consolidate 2 search boxes to 1 is to simplify the interface, but at the same time, we want this additional functionality.
A JComboBox doesn't seem to be able to handle something like this, and my search for alternatives isn't yielding anything. I know this question is somewhat of a broad design question, perhaps not appropriate for stack exchange. I'm still fairly new to Java, so any suggestions are appreciated.
UPDATE: One of the commenters asked for something more specific and pointed out the existence of different types of iTunes searches based on context, which I'd like to disambiguate. Taking a look at how iTunes does it, I decided to try to mock up a graphic of what I was thinking I could do:
So given this specific example, I envision separating the combo box and the search options, perhaps with a JMenu revealed using a button made to look like iTunes' search options feature.
So my evolved questions are (based on the above mock-up):
Can JMenu do this or is there another type of button-initiated menu I should use?
Can menu selections trigger a re-population of the list the JComboBox provides or would that have bad side-effects?
How can I alleviate the confusion of having a drop-down on either side of the search field?

Looking for advice on a first android application (loading data/populating data)

to start with I've gone through the entire notepad tutorial, I'm a professional game programmer who has some extra time. (though most of my time has been in C++, I did take a year or two of Java classes in college, and remember some of it).
I'm not sure the site is a good site to ask questions like this.. If someone has a Forum that might be a good place to ask these newbie questions, please feel free to point me in the direction.
I've examined a few of the samples, and think I've a grasp of what I want to do. I've a three to four project plan for some Android releases to sharpen my skills, but since this is my first project and I have never really developed for a mobile phone or the android before, I'd like to make sure I have a solid plan.
The first project is an example of the license plate game, however I want to do a few things to change it. Heck maybe when I'm done it'll become a bingo style game, with bluetooth connectivity, you never know.
The base idea is I want to offer a list of states, with checkboxes next to them. so to do this, I'll be starting with a Linear List layout similar to the note pad example, and then have a row that is only a Checkbox. I can use text and call strike through if it's been checked off. Perhaps offer an option to not show them if they are checked.
But I want the list to be generated from a set of lists. Maybe all of America's states, maybe reasonable American states (no Hawaii, no Alaska) maybe a North American list, (add in Mexico and some Canadian provinces), a European list, who knows.
I'd probably have to have a pop up window that lists all of the lists I suppose using a radiogroup of some sort.
So then as far as the data, after weighing options I think best solution is to make a database with two fields, "checked" and "name".
I figure I can use the menu for most of the user interaction (aside from clicking on stuff we want to check off) with maybe a few context menu items, I understand how to make all of those already so I should be good.
The question I have is what is the best way to populate the lists? Should I create raw data, and have different files for all the lists? Or is there some other way to do this? I've seen this done on the searchable dictionary, but I'd like to hear what people who have actually generated the data like this before.
In addition is there an easy way to look at the sql database these applications create, or do you have to run searches on them and output the data?
Finally any other suggestion or advice? I definitely want to try to get something like this on the market so I can see the full life cycle and see if anyone actually likes it. (luckily there's not a plethora of them already) but I also want a few people to look over my code if they're willing when I'm done to make sure I've done this right or at least not missing any basic mistakes.
Thank you for your time,
Frank
As far as check boxes, you can design your list item layout to have a checkbox in it. You should make some sort of object that will hold all of the data for each list item, including the status of their checkbox (something like isChecked). Instead of storing a list of String objects containing the names of states, you should have a list of State objects. then, say you wanted to take some action on every checked item, you can easily iterate through the list you gave to the ListAdapter and see which ones are selected.
Was this helpful?
You can stick to C++ if thats your thing (there are some limitations, there are some benefits) , please read this primer for details.
For data folks are going to steer you towards SQLite since is available OOTB with Android.

"Spotlight" like component for Swing?

I am just thinking about ways to improve the user experience for our data entry application and thought about a Mac OS X Spotlight like search bar which allow the user to search for arbitrary terms and pick from a list of choices that match the terms.
I imagine something that is capable of showing categories (like contacts, appointments, mails etc.) and the related results simultaneously.
Do you know of any Swing component that is readily available somewhere, so I would not need to create the UI part again, but concentrate on the actual "search plugins"?
Like the search tool? or the "spotlight" visual where everything is dimmed but there's a light shining on the things that match?
If you're talking about a UI component, the "Swing Hacks" O'Reilly book has a spotlight example.
If you're talking about search/indexing, i'd recomment Apache Lucene. Not sure that anyone
[edit:my answer was cut off right here?]
has a ready made fully functional search results browser like spotlight has now.
Offhand, I cannot think of a "ready made" component for what you are looking at but you may find the following interesting:
macwidgets
This is a collection of "mac style" widgets, such as a "heads up display" and sidebar lists similar to the ones you find in iTunes.
You may want to try adapting some of them to what you need.

Categories

Resources