This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Any experience with JInternalFrame class?

 
George Thomas
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 tree...so 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
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
George,
Maybe you could try using the setSize method, instead of setPreferedSize(). For example: jif.setSize(100, 200);
Mike
 
George Thomas
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike,
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.
George.
 
Chris Shepherd
Ranch Hand
Posts: 286
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
desktop.add(jif);
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,
Chris
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>http://java.sun.com/docs/books/tutorial/uiswing/components/components.html </url>

[This message has been edited by Chris Shepherd (edited July 11, 2001).]
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
George Thomas
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
George.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic