• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

How to size jsplitpane?

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, thanks, i understand, but how can i do this for my splitpane in the panel?
regards kay
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks it works fine!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic