/* * 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); } }