Hello!
There was such a question.
If I make a Swing application, I draw a textField there, I enter data into it, then how can I get this data in another class?
After all, it turns out that we have a GUI in one Thread (in the event dispathc thread), and the required class is in the other.
And how to transfer the data there, in GUI from a class?
- Create an object of your class in the JFrame constructor. - arg
- @aarexer, If you are given a comprehensive answer, mark it as correct (click on the check mark next to the selected answer). - Nicolas Chabanovsky ♦
|
2 answers
I do not remember exactly, but you can synchronize via SwingUtilities.invokeLater()
or SwingUtilities.invokeAndWait()
. Dig in this direction, this is exactly what you need. Unfortunately, literally now I will not give the code, I have not written for a long time.
|
Make a JTextField declaration with a static field, and get the data from there using the <polyname> .getText () method; whenever you want
|