View Single Post
Join Date: Jun 2007
Posts: 59
Reputation: Chaster is an unknown quantity at this point 
Solved Threads: 3
Chaster Chaster is offline Offline
Junior Poster in Training

Re: need help with jbutton and new jframe

 
0
  #2
Jun 16th, 2007
Hi!
You could define a method, let's say popUp():
  1. private void popUp()
  2. {
  3. JFrame frame = new JFrame("aName");
  4. frame.setSize(500, 500);
  5. frame.setVisible(true);
  6. }
Now, you should have an actionPerformed method:
  1. public void actionPerformed(ActionEvent event)
  2. {
  3. if (event.getSource() == button1)
  4. {
  5. popUp();
  6. }
  7. }
Assuming, you have defined the following line:
  1. button1.addActionListener(this);
Oh, and one more thing, your class has to implement the ActionListener interface.
Reply With Quote