import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class ButtonExample { public static void main(String[] args) { JFrame frame = new JFrame("Button Example"); JPanel panel = new JPanel(); JButton button = new JButton("Click me!"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println("Button is clicked!"); } }); panel.add(button); frame.add(panel); frame.setSize(200, 200); frame.setVisible(true); // simulate button click using doClick() button.doClick(); } }This program creates a simple window that contains a button. When the user clicks the button, it prints a message to the console. The `doClick()` method is called after the button is added to the window, and it triggers the button's ActionListener, which prints the message to the console. The package library used in this code example is javax.swing.