*
The moose likes Swing / AWT / SWT and the fly likes Separator in JToolBar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Separator in JToolBar" Watch "Separator in JToolBar" New topic
Author

Separator in JToolBar

Jeremy Hooie
Ranch Hand

Joined: Aug 22, 2001
Posts: 38
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
Joel Cochran
Ranch Hand

Joined: Mar 23, 2001
Posts: 301
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?


Wait a minute, I'm trying to think of something clever to say...<p>Joel
Jeremy Hooie
Ranch Hand

Joined: Aug 22, 2001
Posts: 38
I set the size on the JSeparator, but it had no effect.
Jeremy
Michael Szul
Ranch Hand

Joined: Sep 18, 2001
Posts: 57
You could always extend JToolBar and override the addSeparator() method to display whatever you want it too.
jamie ong
Greenhorn

Joined: Nov 05, 2001
Posts: 24
my separator came out when i use this code.
toolbar.add(new JSeparator(1));
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Separator in JToolBar
 
Similar Threads
separator in not visible ?
Problem with toolbar separator in JDK 1.4.2_06
I'm stuck with calculator GUI
Separator in JToolBar
How to remove space around JSeparator