aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JInternalFrames containing JPanels (resize and move problems) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JInternalFrames containing JPanels (resize and move problems)" Watch "JInternalFrames containing JPanels (resize and move problems)" New topic
Author

JInternalFrames containing JPanels (resize and move problems)

Mr. Ciribomflax
Greenhorn

Joined: Apr 17, 2010
Posts: 2
Hey, I'm rather new to GUI and ran into the following problem:
I extended the JInternalFrame class so that it contains a JSplitPane. The lower pane has only a JFrame that I also extended in order to override the update() and paint() methods.
Now, if I draw something and resize the internal frame that contains the extended JFrame, my drawing simply disappears. It flickers a bit while I'm resizing but it isn't there when I release the mouse button.
Also, if I have more internal frames and move one of them around all the drawings overlap and appear on the upper-most internal frame. It just looks like hell...
I've tried adding some listeners but nothing has worked so far.
Please help..
Thank you!
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2189
    
    7
I extended the JInternalFrame class so that it contains a JSplitPane.


There is no need to extend a class to do this. You just add the split pane to the internal frame.

The lower pane has only a JFrame


You can't add a JFrame to any Swing component so that doesn't make sense.

a JFrame that I also extended in order to override the update() and paint() methods.


You should never do that. Overriding those methods is an old AWT trick and should NOT be used with Swing. Instead you override the paintComponent() method of a JPanel (or JComponent) and add the component to the frame. Read the section from the Swing tutorial on Custom Painting for more information at examples.

If you need more help you should create a SSCCE, that demonstrates the incorrect behaviour.

Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
 
Don't get me started about those stupid light bulbs.
 
subject: JInternalFrames containing JPanels (resize and move problems)