Search code examples
javaswingnetbeansjtextfield

Java Swing update TextField without any action


I created an app in netbeans using swing where i have several JTextFields that i want to update in a cycle without using a buttonactionclick... the problem is when i put in the code of netbeans jFieldText1.setText("test"); in main or in a function... it doesn't appear in the gui... is there any way to do this without having to press a button to update the results?

what i want to do is keep polling using a cycle that updates the JTextField.

thanks...


Solution

  • it doesn't appear in the gui.

    I hope above is for the text you want to see in your jtextfield1

    What you need to do is put your code to change the text in JTextField in some Java Swing event. You can refer this document about Java Swing EventsListeners and ActionListeners.

    There is a method of JButton by which you can click the button on some Event or Action which is button.doClick().