import java.awt.*; import java.awt.event.*; import javax.swing.*; class Counter { private static int count = 0; public static void main(String[] arg) { try { UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() ); } catch (Exception e) { System.exit(1); } JFrame vindu = new JFrame("Counter"); vindu.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(); vindu.add(panel); JButton counterButton = new JButton("Count: " + count); counterButton.addActionListener(e -> { count++; counterButton.setText("Count: " + count); }); panel.add(counterButton); vindu.pack(); vindu.setLocationRelativeTo(null); vindu.setVisible(true); } }