Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132930 views
License: OTHER
1
public class test {
2
public static void main(String[] args) {
3
JFrame frame = new JFrame("My title!");
4
frame.setVisible(true);
5
frame.setSize(300, 150);
6
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
7
8
JPanel panel = new JPanel();
9
frame.add(panel);
10
11
JLabel label = new JLabel("my label");
12
panel.add(label);
13
14
JButton button = new JButton("my button");
15
panel.add(button);
16
button.addActionListener(new MyAction());
17
}
18
19
static class MyAction implements ActionListener {
20
@Override
21
public void actionPerformed(ActionEvent e) {
22
JFrame frame2 = new JFrame("clicked");
23
frame2.setVisible(true);
24
frame2.setSize(200,200);
25
}
26
}
27
}
28
29