-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLaunchWindow_09.java
More file actions
40 lines (34 loc) · 1.21 KB
/
Copy pathLaunchWindow_09.java
File metadata and controls
40 lines (34 loc) · 1.21 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
package GUI;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class LaunchWindow_09 implements ActionListener{
private JFrame frame = new JFrame("Lanucher");
private JButton button = new JButton("new window");
LaunchWindow_09(){
frame.setSize(420, 420);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(null); // required for using setBounds() method
button.setFocusable(false);
button.setForeground(Color.GREEN);
button.setBackground(Color.BLUE);
button.setBorder(BorderFactory.createLineBorder(Color.RED));
button.addActionListener(this);
button.setBounds(100, 160, 200, 40);
button.setHorizontalTextPosition(JButton.CENTER);
button.setVerticalTextPosition(JButton.CENTER);
frame.add(button);
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e){
if(e.getSource() == button){
frame.dispose(); // dispose/close the current window/frame
new NewWindow_09();
}
}
public static void main(String[] args){
new LaunchWindow_09();
}
}