Solved

Vertical bar separator in Toolbar

Posted on 2001-07-24
11
1,597 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

919 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now