-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreading.java
More file actions
47 lines (38 loc) · 1.46 KB
/
Copy pathThreading.java
File metadata and controls
47 lines (38 loc) · 1.46 KB
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
44
45
46
47
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Threading extends JComponent implements Runnable{
/** INITIAL THREADING FRAME */
JFrame initialFrame;
Container threadingContent;
JPanel threadingPanel;
JButton newWindow;
ActionListener threadingListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == newWindow) {
SwingUtilities.invokeLater(new ClientGUI());
}
}
};
public static void main(String[] args) {
SwingUtilities.invokeLater(new Threading());
}
public void run() {
/** CREATE INITIAL FRAME FOR THREADING CLIENT GUI */
initialFrame = new JFrame();
initialFrame.setTitle("Welcome");
initialFrame.setSize(200, 100);
initialFrame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
initialFrame.setLocationRelativeTo(null);
threadingContent = initialFrame.getContentPane();
threadingContent.setLayout(new BorderLayout());
threadingPanel = new JPanel();
newWindow = new JButton("New Window");
newWindow.addActionListener(threadingListener);
threadingPanel.add(newWindow, BorderLayout.CENTER);
threadingPanel.setVisible(true);
threadingContent.add(threadingPanel, BorderLayout.CENTER);
initialFrame.setVisible(true);
}
}