Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. package testMethods;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5.  
  6. import javax.swing.JButton;
  7. import javax.swing.JFrame;
  8. import javax.swing.JOptionPane;
  9.  
  10. public class ListenerPane extends JFrame {
  11.  
  12.     JButton createPane = new JButton("create");
  13.    
  14.     public ListenerPane() {
  15.         this.setSize(500,500);
  16.         this.setVisible(true);
  17.         this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  18.        
  19.         this.add(createPane);
  20.         initListener();
  21.     }
  22.    
  23.     private void initListener() {
  24.         createPane.addActionListener(new ActionListener() {
  25.            
  26.             @Override
  27.             public void actionPerformed(ActionEvent e) {
  28.                 JOptionPane.showMessageDialog(null, "Test", "test2", 0);
  29.             }
  30.         });
  31.     }
  32.    
  33.     public static void main(String[] args) {
  34.         // TODO Auto-generated method stub
  35.         new ListenerPane();
  36.     }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement