-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
36 lines (30 loc) · 1.03 KB
/
Main.java
File metadata and controls
36 lines (30 loc) · 1.03 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
package com.lijin.JSQ;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame("计算器");
JButton basicButton = new JButton("基础计算器");
JButton scientificButton = new JButton("科学计算器");
basicButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new BasicCalculator();
}
});
scientificButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new ScientificCalculator();
}
});
JPanel panel = new JPanel();
panel.add(basicButton);
panel.add(scientificButton);
frame.add(panel);
frame.setSize(300, 100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}