wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Opening a JInternalFrame from another java file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Opening a JInternalFrame from another java file" Watch "Opening a JInternalFrame from another java file" New topic
Author

Opening a JInternalFrame from another java file

Petereyup Smith
Greenhorn

Joined: Aug 18, 2011
Posts: 7
Hi, I hope someone can help (I have searched and not found an answer)
I am trying to create an application using JInternalFrames, I have got this to work, but I would like each internal frame and it components in its own java file.

I am using Netbeans as an editor.

In the below code, the 'test' is in an another java file, and when I add the internal frame to the desktop pane, it creates a whole new window and puts the frame in that.
Is there a way I can get the frame created in 'test' to be part of the original JFrame created in the CleanEnergy class(This is the main class)?

Thanks for any help!

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
this would be one way - change test():


and in addCustOption.addActionListener(..) change
//test cust = new test();
to
dtp.add(new test());

also, in your addCustomer() method, each time it is called it will add
an actionListener i.e. unless you remove the listener, or move it outside the method,
you will end up adding numerous duplicates each time you add a customer
Petereyup Smith
Greenhorn

Joined: Aug 18, 2011
Posts: 7
WOW! That is great!!

It works.

Thanks!! I was starting to pull my hair out!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Opening a JInternalFrame from another java file
 
Similar Threads
Can't generate java classes from WSDL file
Problem with JInternalFrame transperency with Windows Look and Feel
DataBase drivers in Linux
JDesktopPane creates inner frame menuItem actionPerformed does not.
How to set background Color to JFrame when we use Window Look and Feel