I am currently coding an application, which has an option frame JDialog. This frame contains various checkboxes and text fields that the user can configure.
I want to save the changes the user made to the options.
What is the best way of doing so?
My first thought was implementing it by saving it in a file with the format of e.g.
checkBox1=value;
textArea1="value";
By using the following I could get the field, but I would need to do something like (for the checkbox) myField.isSelected(); which does not work.
Field myField = MyClass.class.getDeclaredField(name);
Thank you in advance.
You can use java.util.prefs.Preferences to store the configuration in your JDialog. This question - Java Preference Manager - discuss about how to create frontend+backend solution by using Preferences (something like JFace org.eclipse.jface.preference)
Related
How can I design a editable form as in detail of a person by clicking edit button and edit the respective fields of person's details and save it on the same place where they are shown.
eg.
Full Name : JTextField1
Address: JTextField2
and so on...
Now What I want is to save those values on respective places and when I want to edit them then show editable textfield with same values displayed.
Are there any API's or plugins to do it or should I just have to do as setVisible(true/false) for necessary action to perform??
If you are using JavaFX, you can use setEditable(boolean), which will disable or enable the field for editing. You can also use setDisabled(boolean) to disable the field for anything other than viewing.
If you are using Swing/AWT, you can use setEditable(boolean) as well as setEnabled(boolean) to do the same as JavaFX.
Since you are using Swing/Awt, use setEditable to disable or enable the fields when you press the Edit button. :)
I am looking for a way to create a popup dialog box when a user double clicks a textinput field that will contain a scroll-able list (from database table) where the user can select a field, hit ok, and have it placed into the textbox when popup closes.
The other major requirement is to have a filter/ or search field in the popup to aid the user in finding the correct option to select from quicker.
What is the best way to implement this?
Modification to gwt's popup panel? maybe a JOptionPane? are there any simple solutions already designed for free commercial use?
You could implement this with a com.google.gwt.user.client.ui.PopupPanel. You can make a PopupPanel that contains a ListBox with your data from the database, along with a OK button. When a user selects a value and hits OK, you should utilize an EventBus along with a custom Event that will pass the value to the field on the page. The page will have an event handler that will catch the event and put it into the field.
Another option is to use a com.google.gwt.user.client.ui.SuggestBox. It is a box that autocompletes / suggests values as you type, kind of like the Youtube search bar.
I can offer more resources to help you accomplish this, if you'd like.
I'm trying to create a java gui, currently I'm playing around in the netbeans IDE using their gui creator, but I've also been reading a book about Swing and trying to learn it that way as well. Im hoping someone can help me with a problem I'm having. I'm attempting to allow users to have a "pool" of fields they can choose from (for instance a title, a paragraph, a text fiend, buttons, etc) and be able to move items from the pool into another potion of the window which would let them create their own layout. At this point I don't need these fields to DO anything, but I do want the user to be able to move them around and create their own layout. Is there any way to do this?
I think that to do this, you'd need to use a null layout on the container that would hold the movable components, and you'd have to give the components MouseListeners and MouseMotionListeners (conveniently combined into MouseAdapters) that are active when the program is in the set-up state, but then inactive when the program's components have been all set.
You could use the DragLayout from the tips4java website.
How can I add linux like tab completion to jFileChooser's File Name input field? I'm assuming I need to add a listener to the File Name's text input box to listen for the tab key. But I don't know how to do that. Then once a tab key is hit, I need to look at the directory for files/dir that start with what was inputted. Any ideas on how I can go about doing this?
Emm... I am not pretty sure what the question is but if you want to control is the textfield does contain a file name or something you can simply use JFileChooser as a panel and, as I may remember, there is a way to show/not show its components like "open"/"save"/etc buttons and, of course, replace them with your own; so there should be a way to control its input field I guess. So you need to play around UIManager
For more information you can read this , this and this
If it is not the point... so I still hope you configure your question in a more detailed manner because it is quite unclear :)
Good luck
My problem is the following: I have a Java application, and I would like to create a setup form on it, so i can declare some variables.
How can it be done? And when the setup form is on focus, it should be disabled to perform actions on the main form.
Thanks for any help.
hectai
Create a JDialog and fill it the controls required to display/change options.
One of the JDialog constructors accepts a boolean argument that tells the dialog to be modal, meaning that the user will be unable to focus on the main form.
If you are using AWT, use Dialog instead of JDialog.
You have wide choice :
1- Java Makefile
2- Setup Maker 1.0
3- I recommended : JSmooth
Use swing. When you press "Save" you store the global variables of your app. If you wanna you can show this form at the start of your app.
As jassuncao posted - you're looking for a JDialog to present this to the user. I'd also suggest using the Java Preferences API over setting variables directly. Preferences has support for saving values between runs, using defaults if no value is provided, etc.