• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ActionListener problems

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic