File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes 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 "JInternalFrame" Watch "JInternalFrame" New topic
Author

JInternalFrame

mitesh mehta
Greenhorn

Joined: Aug 29, 2002
Posts: 25
I am having a simple application wherein a JFrame is having JPanel.I want to add an JInternalFrame within that JPanel.I would like to know whether is that possible?
I have tried with JDesktopPane but the JDesktopPane and the JInternalFrame are not visible.
Can anyone please help.
Thank you.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You should place JInternalFrames in JDesktops... maybe if you posted the code you used we could help fix the problems you had with it?


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
mitesh mehta
Greenhorn

Joined: Aug 29, 2002
Posts: 25
The code is as follows :-
JPanel panel1 = new JPanel();
panel1.setVisible(true);
panel1.setBackground(Color.red);
JDesktopPane desk = new JDesktopPane();
desk.setBackground(Color.blue);
JInternalFrame frame = new JInternalFrame();
frame.setBounds(0,0,100,100);
frame.setVisible(true);
frame.show();
JInternalFrame frame1 = new JInternalFrame();
desk.add(frame1);
frame1.setLayer(new Integer(2));
frame1.setBounds(0,0,150,150);
frame1.setVisible(true);
frame1.show();
desk.add(frame);
desk.setVisible(true);
panel1.add(desk);
panel1.setVisible(true);
panel1.invalidate();
getContentPane().add(panel1);

///
When i ask for the desktopPane to return all the frames by the getAllFrames() i get the number of InternalFrames added to the desktopPane.But they are not visible.
Mitesh
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

The problem is that the JDesktopPane component does not have a preferred size... so when you add it to a JPanel (with default FlowLayout) it has size 0, and doesn't display. Either set BorderLayout on the JPanel and add the desktop to the center or call setPreferredSize() on the desktop.
mitesh mehta
Greenhorn

Joined: Aug 29, 2002
Posts: 25
Thank you very much Nathan.
It worked.
Thanks a lot.
Mitesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JInternalFrame