Volazh Volazh - 1 year ago 170
Java Question

TextField waiting for a user input

I got a JTextfield a GetText method, and an array to store the numbers logged on the Jtextfield.

JTextField tf1 = new JTextField();

String tfone = tf1.getText();
int one = Integer.parseInt(tfone);

int[][] array = new int[4][5];
array[0][0] = one;
array[0][1] = otherValues...

The problem here is, that code execute all, so no wait for a user input into the JtextField. How can i make the jtextfield wait, until an user log in something. To latter on execute the Integer.Parseint ?

I can no change JtextField by another method cuz I'm working with GUI (Graphic User Environment.)

Answer Source

You may try adding Button and then perform it's ActionListener and then enter the input and pressing the button will load the code of doing the stuff you want.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download