-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThreadsExample.java
43 lines (39 loc) · 1.27 KB
/
ThreadsExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package Projects;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
//import com.sun.java.swing.*; //old package name
import javax.swing.*; //new package name
public class ThreadsExample {
/**
* This is strictly boilerplate: set the look and feel, configure the
* frame, pack(), show().
*/
public static void main(String[] args) {
String laf = UIManager.getCrossPlatformLookAndFeelClassName();
try {
UIManager.setLookAndFeel(laf);
}
catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
JFrame f = new JFrame("Worker Thread Examples");
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
};
f.addWindowListener(l);
Container contentPane = f.getContentPane();
final Example1 ex1 = new Example1();
contentPane.setLayout(new GridLayout(1, 0));
contentPane.add(ex1);
contentPane.add(new Example2());
f.pack();
f.show();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ex1.getStartButton().requestFocus(); //XXX: can't do this until now
}
});
}
}