I want to change the text of a JLabel outside of the method I created it in.
I've looked through the other pages on the same topic but I still cannot get it to work. Perhaps I am lacking knowledge of Java to solve this by myself.
Would you please help me?
package autumn;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Main {
private JFrame frame;
JLabel TestLabel;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Main window = new Main();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Main() {