• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Separator in JToolBar

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there an easy way to add a vertical line separator in JToolBar? The addSeparator() method just adds empty space and adding a JSeparator to the toolbar gives the desired look, but also adds empty space forcing the remaining components to the end of the screen.

Any Suggestions?
Jeremy
 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my GUI I have blank space as well. JToolBar has a nested class for tool bar specific separators, but it doesn't appear to have capability to set separators or make them visible.
The result is the same with each of the following examples...

From the 1.4 API...


public static class JToolBar.Separator
extends JSeparator
A toolbar-specific separator. An object with dimension but no contents used to divide buttons on a tool bar into groups.


I guess since it has no contents it has nothing to display.
Since you are using the JSeparator class instead of the JToolBar.Separator class, have you tried using JComponent's
setPreferredSize( Dimension d ) method?
 
Jeremy Hooie
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I set the size on the JSeparator, but it had no effect.
Jeremy
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could always extend JToolBar and override the addSeparator() method to display whatever you want it too.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my separator came out when i use this code.
toolbar.add(new JSeparator(1));
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!