Advertisement
zoro-10

BtnClkDemo.java

Mar 30th, 2024
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. import java.awt.event.ActionEvent;
  2. import java.awt.event.ActionListener;
  3. import javax.swing.*;
  4.  
  5. public class BtnClkDemo {
  6.  
  7.   public static void main(String args[]) {
  8.     JFrame frame = new JFrame("Button Click Demo");
  9.     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  10.     JButton button = new JButton("click Here");
  11.     button.addActionListener(
  12.       new ActionListener() {
  13.         @Override
  14.         public void actionPerformed(ActionEvent e) {
  15.           JOptionPane.showMessageDialog(frame, "Button Clicked!");
  16.         }
  17.       }
  18.     );
  19.     frame.getContentPane().add(button);
  20.     frame.pack();
  21.     frame.setVisible(true);
  22.   }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement