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