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

Any experience with JInternalFrame class?

George Thomas
Ranch Hand

Joined: Oct 06, 2000
Posts: 35
I have a Swing application running as a class which extends JApplet.
Various components are initialized and finally added to the content pane as below:

Now I'm going to add a menu item which will have a search function for the I have have a listener which will then create a JInternalFrame ( I need the window to be somewhat persistant so I can have 'find next' type functionality).
The internal frame is created but always is maximized below the menu bar...I can't get the blasted thing to just display at a given size.
Here is the code that doesn't display the correct size of the JInternalFrame:

If it wasn't for the fact that I'm bald and have a buzz cut I'd be pulling my hair out right now. Please save me before I go for the tweezers!!!
Mike Leghorn

Joined: Jul 10, 2001
Posts: 8
Maybe you could try using the setSize method, instead of setPreferedSize(). For example: jif.setSize(100, 200);
George Thomas
Ranch Hand

Joined: Oct 06, 2000
Posts: 35
Thanks for the reply...I think I tried that already but I'll try it again just in case.
I was doing some searches on the problem and apparently there are numerous bugs in jdk 1.3 relative to the sizing of the JInternalFrame.
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
Hmmm looks like you are adding this directly to the contentPane you want it in. JInternalFrame is meant to be used inside of a JDesktopPane component. Typicaly you:

JDesktopPane desktop=new JDesktopPane();
setContentPane=desktop; (or just add the desktop to the contentpane)
(and assuming your example code)
the desktop should honor all your settings for that internalFrame. You may not need to pack() and you don't need to show() your internalFrame. The desktop should do that for you.
(if you are using a desktop already, then I haven't a clue)
Hope this helps,
looking back at what your design goal is, are you sure you want to use an internalFrame? Sounds more like you need some sort of modal window. Have you checked out the tutorial site for the GUI components? I often find it useful to help me decide which component would work best in a situation. go to <url> </url>

[This message has been edited by Chris Shepherd (edited July 11, 2001).]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

If someone hasn't already fixed it for you, remove the pack() line. That seemed to work for me when I had a similar problem. And don't let people discourage you from Internal Frames. They work great once you get to know them.

GenRocket - Experts at Building Test Data
George Thomas
Ranch Hand

Joined: Oct 06, 2000
Posts: 35
Thanks Chris,
You are probably right, I have the constraint of planting this applet right onto the HTML page so I can't subclass JFrame which opens up a separate 'Java Applet Window'. As I've been developing this I've come to the conclusion that some of these components behave 'differently' on the JApplet container than on the JFrame. (I can get my drag and drop routines for the tree to work by sub classing JFrame but the drop events don't fire when I sub class JApplet.) Yes, I probably need to use the JDesktopFrame (although my big Swing book (O'Reilly) says you can use any container). I tried that and I was probably doing something wrong with that cause my controls wouldn't paint on top of it at all...I just got the JDesktopFrame (?). Unfortunately I don't have time to do much controlled experimentation...this search thing is required for an upcoming demo of the application...(crunch). So I've come up with the idea of adding a tab for the search criteria to make them persistant and then another to display the results. When things quiet down I'll get back to this. Who am I kidding? Things don't quiet down here !
Thanks again.
I agree. Here's the link:
subject: Any experience with JInternalFrame class?