aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to size jsplitpane? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to size jsplitpane?" Watch "How to size jsplitpane?" New topic
Author

How to size jsplitpane?

Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
Hi,
I have a JFrame with a JPanel. This JPanel contains a JSplitpane, wich has alwasy the size of the JPanel. I need to size the Splitpane to the size of the JFrame... how can i do this?
The JSplitpane only "knows" the size of the JPanel, but not of the JFrame.
Please help...I tried a lot, but found no solution.
Thanks lot!
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
It seems to me, that you want to show your frame in the same size like the splitpane? If this is so, then you can try JFrame.pack().
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
no, i want the jsplitpane to have the size of the frame. my problem is the splitpane is in a panel and this panel dont know the size of the frame where its added.

thanks....
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Which kind of LayoutManagers do you use?
For example if your Frame (ContentPane) has BorderLayout and you add a JPanel to the Center, then it has the same size like your Frame. And if Your Panel has also BorderLayout and your JSplitPane is added to the center, then it will have also the same size like your Frame.
But maybe you have some other components to show??? You shoud give us a bit code. This makes our thoughts a bit easier. Maybe not the whole application, only the skeleton (GUI).
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
ok, here is the gui in a simple way. i wrote it for you to understand and in addition to that i solved my problem :-) But i have another problem with "splitPane.setDividerLocation(0.5);", because there is no effect. the divider should be in the middle and i want to use percentage. Can you help, please? thanks!

Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Yes, you missed something. It is only possible to call setDividerLocation(0.5) when the JFrame is already opened. So you have to listen for this event.
Here is a little example:

Hope this helps
Rene
[ June 26, 2002: Message edited by: Rene Liebmann ]
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
ok, thanks, i understand, but how can i do this for my splitpane in the panel?
regards kay
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
This is easy. Your SplitPane exists in your Class MainPanel. And you create your MainPanel instance in your Frame. So your MainPanel should implement
the WindowListener interface. Then you add your instance of MainPanel as a WindowListener to your Frame.
Or (a bit easier) you make it in a different way. You could add a method setParentFrame(JFrame frame) to your MainPanel class. This method could look like:

Do you understand the Idea? It doesn't matter where you catch the windowOpened Event. You can do it where ever you know your Frame.
Bye
Rene
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148
Thanks it works fine!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to size jsplitpane?