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

JSplitPane problem

Osama Al-Haj Hassan
Greenhorn

Joined: May 24, 2009
Posts: 6
Hi there;

I'm creating a GUI where I have a JFrame which has a JSplitPane that works as a divider between a JDesktopPane on one side and JTextArea on the other side. The problem is that I'm using the JDesktopPane side to:
1- Add new "JInternalFrames"
2- Draw some "graphics"

When I try to resize the JSplitPane. My JDesktopPane is repainted which undo all the changes I made in it. For example, I moved several JInternalFrames and then I resized the JSplitPane and that made my JInternalFrames go back to their initial locations. How can I avoid this? In other words, How can I cancel the effect of resizing JSplitPane on the contents of my JDesktopPane?

Thanks for help,

Java Lover.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
sounds like you're doing your drawing via getGraphics(),
and your problem is the exact reason why getGraphics() should not be used.

it draws things once only, then any change and *poof* its gone.
Osama Al-Haj Hassan
Greenhorn

Joined: May 24, 2009
Posts: 6
Actually, I have not started drawing yet. But I think If I draw anything, then I suspect the result to be the same as what is happening with the JInternalFrame. For now, I want the JInternalFrame problem to be solved. Can anyone solve the JInternalFrame problem which I explained earlier???

Thanks,

Java Lover.
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
I created a small program to try to replicate your problem, and I couldn't: the internal frames remained where I placed them when I moved the splitpane's divider. Here is the code that demonstrates this:


I think that the problem is that you've got a bug in your code, and for us to help you solve it, you'll have to post that code, preferably in a small compilable and runnable program similar to what I've posted above. Best of luck.
Osama Al-Haj Hassan
Greenhorn

Joined: May 24, 2009
Posts: 6
I checked you code Pete. This is exactly what I want. May be there is a bug in my code.

One more thing, if I ("move the internal frames") outside the area boundaries, I want a horizontal and vertical scrollbars to appear so that I can see the rest of the internal frames. How can I do that? Do I have to implement an event handler that detects x,y locations for internal frames when they are moved?

Thanks Pete for help.

Java Lover.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSplitPane problem