File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Problem with JSplitPane and JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem with JSplitPane and JFrame" Watch "Problem with JSplitPane and JFrame" New topic

Problem with JSplitPane and JFrame

dziubut dziubucinski

Joined: Sep 14, 2010
Posts: 8
Hi all I'm stuck...
I have a frame and jsplitpane on it. JSplitPane has 2 components: (left)panel with several labels and buttons, and (right) jscrollpane which has panel with bufferedimage on it (i draw img using g2.drawImage(...)). Everything works perfect till i try to resize frame - left jsplitpane's component is tryin to disappear (blinkin) and image is moving to left edge of frame. I set left panel (and also scrollpane) minimum size but it doesnt work. Problem appears only when i touch frame..
I would appreciate for any suggestions.
Darryl Burke

Joined: May 03, 2008
Posts: 5093

To get better help sooner, post a SSCCE that demonstrates your problem.

luck, db
There are no new questions, but there may be new answers.
dziubut dziubucinski

Joined: Sep 14, 2010
Posts: 8

Here it is...Try to load an image (Plik->Otworz) and then grab frame and try to resize..
Btw windows, eclipse JavaSE-1.6
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2414
There are a couple of problems:

a) I never like using a null layout because the preferred size is never calculated. Don't know if this is a problem or not.

b) Don't use the add(...) method to add components to the split pane. Use the setLeft/Right component methods.

c) Don't use the removeAll() method. This removes the divider from the split pane. Instead you might just add an empty JPanel.
dziubut dziubucinski

Joined: Sep 14, 2010
Posts: 8
The problem was c).
Thank you for advices!
all the best
I agree. Here's the link:
subject: Problem with JSplitPane and JFrame
It's not a secret anymore!