Get the value from JTextField

Dear all,

I'd like to ask if there is possible to get various JTextFields' values at the same time after clicking the button (e.g. Submit).

Since I can only get the JTextValue when I have press "Enter", however, it's inconvenience to the users if they should press "Enter" after entering each value.

So, will it be possible to do it by clicking a button only?

Thanks.

[401 byte] By [calvin06a] at [2007-11-26 19:33:22]
# 1
Don't understand your question.If you have a reference to the text fields, then you can access any number of text fields when you click the "Submit" button.
camickra at 2007-7-9 22:05:41 > top of Java-index,Desktop,Core GUI APIs...
# 2

You can acheive that by doing the following;

first, declare your JTextFields so that your action listener for the button will have access to them.

JTextField text1;

JTextField text2;

JTextField text2;

then somewhere where you draw your GUI;

text1 = new JTextField("Hello");

text2= new JTextField("Hi");

text3 = new JTextField("Hola");

and later, when the button is pressed (action performed method), you can access these values, for example;

System.out.println(text1.getText()+", "+text2.getText()+", "+text3.getText());

Maykin53a at 2007-7-9 22:05:41 > top of Java-index,Desktop,Core GUI APIs...