This commit is contained in:
2022-05-01 23:24:00 +08:00
parent 0b354c7561
commit 053113577f
16 changed files with 493 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
/*
* Author: CHEN Yongyuan (Walter) from OOP(1007)
* Date: 2022-05-01
* Description: This is the Main Frame class.
*/
import javax.swing.JFrame;
import java.awt.FlowLayout;
import javax.swing.JButton;
public class MyFrame extends JFrame {
// add two buttons with different text
private JButton button1 = new JButton("Button 1");
private JButton button2 = new JButton("Button 2");
public MyFrame() {
setSize(400, 300);
setTitle("MyFrame");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
// set the layout of the frame
setLayout(new FlowLayout(FlowLayout.LEFT, 20, 40));
// add the buttons to the frame
add(button1);
add(button2);
setVisible(true);
}
}