Initial Commit
This commit is contained in:
29
SingleFile/Main.java
Normal file
29
SingleFile/Main.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package SingleFile;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import java.awt.FlowLayout;
|
||||
|
||||
public class Main {
|
||||
private static int counter;
|
||||
public static void main(String[] args) {
|
||||
counter = 0;
|
||||
|
||||
JFrame jFrame = new JFrame("My Single File Counter GUI");
|
||||
|
||||
jFrame.setLayout(new FlowLayout(FlowLayout.CENTER));
|
||||
jFrame.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!");
|
||||
});
|
||||
|
||||
jFrame.add(button);
|
||||
jFrame.setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user