• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ActionListener problems

 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have serveral classes, one of which lays out some buttons on the creen. I want these buttons to open new windows from other classes but I am hvaing trouble. The actionListener is working but how do I get a window containing a new class to open when the button is clicked?
The class with the buttons is

and I want it to open up

Thanks very much
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what the purpose of CreateTest is; you actually want to open up a TestFrame window, right? In any event, CreateTest has no constructor, and definitely not one that takes a JFrame as a constructor argument, so I think there's some confusion here.
What I'd do is just move the few things that CreateTest.main() does either into TestFrame's constructor, or into the ActionListener, and have the ActionListener create a TestFrame directly.
If you really, really, want CreateTest to be involved for some reason, then as the only code in that class is in main(), the ActionListener should invoke CreateTest.main(), something like
CreateTest.main(new String[0]);
 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much! I have created my forms seperatly and am not struggling to fit them into my applications. Stil I have followed your advice and everything is going well.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic