aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JFrame vs JInternalFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame vs JInternalFrame" Watch "JFrame vs JInternalFrame" New topic
Author

JFrame vs JInternalFrame

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.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Why can't you open another JInternalFrame? If you have the reference to your controlling window just create another one.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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


GenRocket - Experts at Building Test Data
Arun Martin
Ranch Hand

Joined: Dec 01, 2000
Posts: 64
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.





 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame vs JInternalFrame