Advertisement
Guest User

Untitled

a guest
May 16th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1.         JFrame frame = new JFrame();
  2.         JPanel panel = new JPanel();
  3.         JButton button = new JButton("Button");
  4.        
  5.        
  6.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  7.         button.addActionListener(new ActionListener(){
  8.  
  9.             @Override
  10.             public void actionPerformed(ActionEvent arg0) {
  11.                 //Code which will be executed when the button is pressed
  12.                 System.out.println("You pressed the button!");             
  13.             }
  14.            
  15.         });
  16.        
  17.        
  18.         frame.add(panel);
  19.         panel.add(new JButton("Button 1"));
  20.        
  21.        
  22.         frame.pack();
  23.         frame.setVisible(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement