OnJava8-Examples/gui/SubmitSwingProgram.java

24 lines
664 B
Java
Raw Normal View History

2015-04-20 15:36:01 -07:00
//: gui/SubmitSwingProgram.java
import javax.swing.*;
import java.util.concurrent.*;
public class SubmitSwingProgram extends JFrame {
JLabel label;
public SubmitSwingProgram() {
super("Hello Swing");
label = new JLabel("A Label");
add(label);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300, 100);
setVisible(true);
}
static SubmitSwingProgram ssp;
public static void main(String[] args) throws Exception {
2015-05-06 12:09:38 -07:00
SwingUtilities.invokeLater(() ->
ssp = new SubmitSwingProgram());
2015-04-20 15:36:01 -07:00
TimeUnit.SECONDS.sleep(1);
2015-05-06 12:09:38 -07:00
SwingUtilities.invokeLater(() ->
ssp.label.setText("Hey! This is Different!"));
2015-04-20 15:36:01 -07:00
}
} ///:~