Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.*;
- public class BtnClkDemo {
- public static void main(String args[]) {
- JFrame frame = new JFrame("Button Click Demo");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JButton button = new JButton("click Here");
- button.addActionListener(
- new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- JOptionPane.showMessageDialog(frame, "Button Clicked!");
- }
- }
- );
- frame.getContentPane().add(button);
- frame.pack();
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement