Solved

Vertical bar separator in Toolbar

Posted on 2001-07-24
11
1,601 Views
Last Modified: 2007-11-27
I've seen vertical bar separators in a few Java applications (JBuilder, TogetherJ). How do you create these? Is this a graphic? The .addSeparator only give me blank separation between buttons.

TIA,
Joel
0
Comment
Question by:joeltt
11 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6315985
Have a look at JSplitPane.
Sounds like this maybe what you are after.

JSplitPane pane = new JSplitPane(JPlitPane.VERTICAL_SPLIT, panel1, panel2);

Or if you just want a visual separator then use JSeperator.

new JSeperator(SwingConstants.VERTICAL);

0
 
LVL 1

Expert Comment

by:chris_kabuki
ID: 6316337
You need to use a JToolBar.Separator()
Check the API but it's really no more that creating an instance of it and then adding it to your toolbar:

.add(new JToolBar.Separator());

Note there is a 'setSeparatorSize()' method to change the size of it if you like. What the separator looks like is goverened by the current L&F.

0
 
LVL 92

Expert Comment

by:objects
ID: 6316375
chris> Isn't that what joeltt is already doing ?

joeltt> I think u can ignore my comment, I misunderstood your question.


0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 92

Expert Comment

by:objects
ID: 6316389
On closer investigation I'll reinstate my JSeparator suggestion :-)
Haven't tested it, but it looks like it'll do what u require.
0
 
LVL 3

Author Comment

by:joeltt
ID: 6317558

Chris, I want to open this back up to other suggestions. I think I was doing what you say already, and didn't see a bar (vertical "3Dish" bar).

When I get back to my code (tonight), Ill check it out to make sure (and award points if you are indeed correct).
0
 
LVL 92

Accepted Solution

by:
objects earned 75 total points
ID: 6320153
addSeparator() simply adds a JToolbar.Separator which is an invisible separator.
The JSeparator on the other hand displays a bar (you've probably seen the horizontal version in menus).

In fact JToolbar.Separator is an extension of JSeparator with an empty paint().
0
 
LVL 3

Author Comment

by:joeltt
ID: 6320549
Well, Chris it works and it doesn't work for me. I do get the vertical bar, but for the life of me can't figure out why any following toolbar buttons are pushed to the far right of the toolbar (up to the next JSeparator).

Any ideas?

Joel
0
 
LVL 92

Expert Comment

by:objects
ID: 6324523
JToolbar.Separator works??? And u get a visual bar?
What JDK version?

0
 
LVL 3

Author Comment

by:joeltt
ID: 6324789

JDK 1.3.1, actually maybe I confused your two answers. Ill have to check again...

Anyway, why would the visual separator push everything after it to the far right?

J
0
 
LVL 92

Expert Comment

by:objects
ID: 6324943
Sounds like a layout issue, I'll see wot I can find out.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9017765
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


[points to objects]


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question