File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes JInternal Frames under JMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "JInternal Frames under JMenu" Watch "JInternal Frames under JMenu" New topic
Author

JInternal Frames under JMenu

Arun Martin
Ranch Hand

Joined: Dec 01, 2000
Posts: 64
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.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
A JInternalFrame should be able to have another JInternalFrame in it. Why didn't you do that?
You can't use a JFrame inside a JInternalFrame, because a JFrame is a heavywieght component - it has a peer on the operating system, and as such needs to be ONLY an outermost container. The main difference that JInternalFrame has is that is does NOT have that native peer, and therefore can be contained in another container.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Arun Martin
Ranch Hand

Joined: Dec 01, 2000
Posts: 64
Hi,
Thanks for the response. 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.





 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JInternal Frames under JMenu