Initial Commit

This commit is contained in:
2024-11-16 11:12:12 -05:00
commit 3902f7929e
5 changed files with 111 additions and 0 deletions

9
CustomJFrame/Main.java Normal file
View File

@@ -0,0 +1,9 @@
package CustomJFrame;
public class Main {
public static void main(String[] args) {
MyJFrame myJFrame = new MyJFrame("My Custom JFrame Counter GUI");
myJFrame.setVisible(true);
}
}

View File

@@ -0,0 +1,29 @@
package CustomJFrame;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class MyJFrame extends JFrame {
private int counter;
public MyJFrame(String title) {
super(title);
counter = 0;
this.setLayout(new FlowLayout(FlowLayout.CENTER));
this.setSize(300, 200);
JButton button = new JButton();
button.setText("Click Me!");
button.addActionListener((v) -> {
counter += 1;
button.setText("You've clicked the button " + counter + " times!");
});
this.add(button);
}
}