• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create a splitter with buttons on it?

 
Marek Krzeminski
Greenhorn
Posts: 14
C++ Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to create a GUI which has a top section, a splitter below it and a main content section below the splitter. I'd like to make the splitter real fat (ie 100 pixels or so high), so that I can place some buttons on it. It could then act like a toolbar in my application.

How would I implement such a thing? Basically the splitter should still behave like a regular splitter when you move it up or down, but it has the added functionality of toolbar buttons on it.
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Split Panes?
 
Marek Krzeminski
Greenhorn
Posts: 14
C++ Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Split Panes?


I was actually looking at that exact website earlier today, but it doesn't explain how I can place buttons On the splitter, or how I could even enlarge the thickness of the splitter to make room for buttons.
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know. Sorry.

Anybody else?
 
Winston Gutkowski
Bartender
Posts: 10571
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marek Krzeminski wrote:I was actually looking at that exact website earlier today, but it doesn't explain how I can place buttons On the splitter, or how I could even enlarge the thickness of the splitter to make room for buttons.

Dunno (and I'm no GUI expert), but several LayoutManager subtypes allow you to expand and contract "sections" any way you like. You might want to look at BoxLayout, which seems a nice compromise between really basic layouts and the Machiavellian GridBagLayout.

Winston
 
Marek Krzeminski
Greenhorn
Posts: 14
C++ Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found that I could use splitPane.setDividerSize() to change the thickness of the divider already. Now I'm trying to use layered panes (http://docs.oracle.com/javase/tutorial/uiswing/components/layeredpane.html) to place buttons on the thick splitter
 
Winston Gutkowski
Bartender
Posts: 10571
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marek Krzeminski wrote:I found that I could use splitPane.setDividerSize() to change the thickness of the divider already. Now I'm trying to use layered panes (http://docs.oracle.com/javase/tutorial/uiswing/components/layeredpane.html) to place buttons on the thick splitter

This sounds incredibly complicated. Get back to basics: What are you trying to do?

And tell us WHAT you're trying to do, not HOW you want to do it.

For instance: a sample of the output you're trying to achieve would be useful.

Winston
 
Marek Krzeminski
Greenhorn
Posts: 14
C++ Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to implement this:


Where the middle section is both a splitter between the top and bottom sections, and a toolbar with buttons.
 
Winston Gutkowski
Bartender
Posts: 10571
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marek Krzeminski wrote:Where the middle section is both a splitter between the top and bottom sections, and a toolbar with buttons.

Well, first off, it isn't a splitter, its the divider of a split pane, and I don't see anything that leads me to believe you can use a divider as anything other than a divider.

Also: if you fill your divider with buttons, how is the GUI supposed to know whether you're clicking on one of them to activate the button or to move the divider? It's possible that one of the more complex LayoutManager's will allow you to use a fixed-height pane as a divider, or even that a nested split-pane (with two dividers) allows you to maintain a fixed-height panel in between them; but, to be honest, it sounds awfully involved.

Like I say, I'm no GUI expert, so there may well be a way to do what you want, but for now my advice would be to keep it simple.

Either use two independent horizontal dividers in a nested split pane, which will perform the same function, just not exactly how you'd like, or think of some other way to display it.

Winston
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to tell us why you wish to have the buttons. What are the buttons supposed to do? Is it to enable moving the splitter? If yes check out JSplitPane#setOneTouchExpandable(boolean expandable) Setting this to true displays two < and > kind of buttons for fast splitting
 
Bernhard Goetz
Ranch Hand
Posts: 57
1
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this idea rather cool, so I made a small implementation
This may come handy at one time. But keep the suggestions of the previous posts in mind. If you need the buttons for toggling the split panes, then use the on-board attributes of JSplitPane.



Regards,
Bernhard
 
Winston Gutkowski
Bartender
Posts: 10571
64
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bernhard Goetz wrote:I found thisidea rather cool...

Bernhard,

Please DontWriteLongLines. It makes the thread very hard to read.
I've broken yours up this time, but for future reference, please remember:
80 characters max.
(the SSCCE page actually recommends 62)
And that includes string literals AND comments AND long method calls.
(And I know it's hard with GUI code because the method calls ARE so damn long )

Thanks.

Winston
 
Bernhard Goetz
Ranch Hand
Posts: 57
1
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
I've broken yours up this time, ...


Thank you so much. I really forgot to check the formatting!
 
Winston Gutkowski
Bartender
Posts: 10571
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bernhard Goetz wrote:Thank you so much. I really forgot to check the formatting!

No probs. Looks like an interesting solution; thanks for sharing. Like I say, I'm by no means a GUI expert.

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!