File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes ActionListener problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ActionListener problems" Watch "ActionListener problems" New topic

ActionListener problems

Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
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

Joined: Jul 08, 2003
Posts: 24199

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]);

[Jess in Action][AskingGoodQuestions]
Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
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.
I agree. Here's the link:
subject: ActionListener problems
It's not a secret anymore!