//PROGRAM 13-1 import java.awt.*; import java.awt.event.*; import javax.swing.*; class MySwingApplication extends JFrame implements ActionListener { public JLabel label; public JButton button; private int numClicks = 0; public MySwingApplication(String title) { super(title); setBounds(0, 0, 300, 170); getContentPane().setLayout(null); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); label = new JLabel("Jumlah klik yang dilakukan: 0"); label.setLocation(60, 40); label.setSize(label.getPreferredSize()); button = new JButton("Klik aku!!"); button.setLocation(60, 80); button.setSize(label.getPreferredSize()); button.addActionListener(this); getContentPane().add(label); getContentPane().add(button); setVisible(true); } public void actionPerformed(ActionEvent event) { if (event.getSource() == button) { label.setText("Jumlah klik yang dilakukan: " + (++numClicks)); } } public static void main(String[] args) { MySwingApplication app = new MySwingApplication("Contoh Event-Handling"); } }