Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Opening a JInternalFrame from another java file

 
Petereyup Smith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WOW! That is great!!

It works.

Thanks!! I was starting to pull my hair out!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic