I have a Java application and I want to open a new dialog from the main interface where the user can enter his name, surname and country and then click ok. How can I open a dialog which has a number of different input fields and then save that information in a variable?
+1
A:
Extend JDialog and add some JTextFields and maybe some JComboBoxes. then finish it off with some JButtons
You could also look into JGoodies Forms framework its nice and free.
EDIT: Composition example
Based on Pete's comment i dug up this example using composition rather than overriding JDialog
You would want to add getter like
public String getFirstName() {
return field.getTest();
}
To gain access to relevant input.
Fedearne
2009-11-06 10:17:52
+1 for reference links
basszero
2009-11-06 10:24:29
Only extend JDialog (or any other class) if you need to override one or more of its behaviours.
Pete Kirkham
2009-11-06 10:30:30
I am not really looking to override any features, just have a set of text boxes that are relevant to my application. I am going create a class that extends JDialog. I will save the text in attributes and then access those attributes from the main application to get the text.not sure how clear my explanation was
thearchitect
2009-11-06 10:35:42
So Pete do you recommend to Wrap the JDialog or how would go about it?
Fedearne
2009-11-06 10:40:05
A:
This forum post could be helpful.
One possibility to make a custom JDialog is to create a custom JPanel with all the bells and whistles that you need and use that as the Component in one of the static JOptionPane functions.
kgiannakakis
2009-11-06 10:19:35