import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class FirstGUI2026 implements java.awt.event.ActionListener {
JFrame frame;
JButton button2;
public FirstGUI2026() {
frame = new JFrame("First GUI 2026");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setVisible(true);
frame.setLayout(new FlowLayout());
JButton button = new JButton("Click Me");
button.addActionListener(this);
frame.getContentPane().add(button);
button2 = new MyButton("Java");
button2.addActionListener(this);
frame.getContentPane().add(button2);
}
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println(e.getActionCommand()+" button clicked!");
frame.pack();
// button2.setPreferredSize(new Dimension(200,100));
}
public static void main(String[] args) {
new FirstGUI2026();
}
}
// class MyButton extends JButton {
// public MyButton(String text) {
// super(text);
// }
// public Dimension getPreferredSize() {
// return new Dimension(200, 100);
// }
// }