OnJava8-Examples/ui/SubmitSwingProgram.java
2015-12-15 11:47:04 -08:00

27 lines
835 B
Java

// ui/SubmitSwingProgram.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
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 {
SwingUtilities.invokeLater(() ->
ssp = new SubmitSwingProgram());
TimeUnit.SECONDS.sleep(1);
SwingUtilities.invokeLater(() ->
ssp.label.setText("Hey! This is Different!"));
}
}