• 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

JFrame vs JInternalFrame

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have designed a JMenu. On clicking each JMenuItem, a JInternal FRAME is invoked (because only JInternal Frame sits perfectly under JMenu). I have a button in the JInternal Frame which on invoked should open another JInternalFrame. I don't think it is possible
I tried invoking JFrame from JInternalFrame. The JFrame was opened but an exception was thrown so I rejected that idea. Is there any other alternative?.
with warm regards,
Arun.
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why can't you open another JInternalFrame? If you have the reference to your controlling window just create another one.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I had that problem at one time too. But I figured out how to do it.
It is something like this:

And then you have a another class file that is your internal frame and you call it anInternalFrame.java
Then from any other internal frame, all you have to do is call the openTheFrame() method and a new window will open.
I know this is kind of crude, but I think it is enough to get you going. Let me know if you need more help.

------------------
Happy Coding,
Gregg Bolinger
 
Arun Martin
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks a lot for the responses. I tried some twiddling of my own with help from ur queries. I am happy to say that I have acheived the desired result. I am here giving out the rough analysis of the code. Before that I would like to state what I precisely I need. I have designed a JMenu and on clicking each JMenuItem,the first JInternalFrame is opened and when a button is clicked a second JInternalFrame should be opened. This is how I went about it
1. Declared a JFrame containing a static Desktop and containing the JMenuItems. On clicking a particular JMenuItem, the first JInternalFrame is opened
public class MainFrame extends JFrame
{
static JDesktopPane desktop;
MainFrame()
{
MenuItem.addActionListener(new ActionListener()
{
InternalFrame1 fr1 = new InternalFrame1();
// invoking the first JInternalFrame
desktop.add(fr1);
fr1.setVisible(true);
fr1.show(true);
}
}// end of constructor MainFrame
} // end of class MainFrame
2. Declaring the the first JInternalFrame,and inside when a button is clicked a second JInternalFrame should be opened
public class InternalFrame1 extends JInternalFrame
{
InternalFrame1()
{
super("title",false,true,false,false);
this.setFrameIcon(null);
// remaining code
}// end of constructor InternalFrame1

public void actionPerformed(ActionEvent evt)
{
InternalFrame2 fr2 = new InternalFrame2();
// invoking the second JInternalFrame
fr2.setVisible(true);
MainFrame.desktop.add(fr2);
fr1.show();

}// end of actionPerformed
} // end of class InternalFrame1
3.The second JInternalFrame2
public class InternalFrame2 extends JInternalFrame
{
InternalFrame2()
{
super("title",false,true,false,false);
this.setFrameIcon(null);
// remaining code
}// end of constructor InternalFrame2
} // end of class InternalFrame2

with warm regards ,
Arun.





 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic