Solved

How to give color to toolbar borders in SWT?

Posted on 2013-06-18
3
344 Views
Last Modified: 2013-06-21
How can I make the white borders of the toolbar the same color as the toolbar background color in SWT and put vertical black lines in between the toolbar groups?

I am sending a screen shot to show the white border lines.
white-borderline.png
0
Comment
Question by:Tolgar
  • 2
3 Comments
 
LVL 16

Assisted Solution

by:Valeri
Valeri earned 500 total points
Comment Utility
ok. follow these steps:
1. every time you create a CustomToolBar create it in this way
CustomToolBar custToolBar12 = new CustomToolBar(compTB, SWT.FLAT, "preferences");
instead of
CustomToolBar custToolBar12 = new CustomToolBar(compTB, SWT.BORDER, "preferences");
the only difference is SWT.FLAT instead of SWT.BORDER. it will remove the borders of the toolbar groups.
2. after the toolbar groups you want to put vertical black lines. to do this after each one of the groups add this code:

Label verticalSepartor = new Label(compTB, SWT.SEPARATOR | SWT.SHADOW_OUT | SWT.VERTICAL);
        GridData sepGD1 = new GridData(GridData.FILL_VERTICAL);
        verticalSepartor.setLayoutData(sepGD1); verticalSepartor.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));

if you want you can capsulate this piece of code in different class to hava your code more readable.

P.S. if you have 3 toolbar groups and 2 vertival black line as separators after the first and the second toolbar group, you have to change GridLayout of the composite that represents your whole toolbar in this way:
GridLayout gridLayout1 = new GridLayout(5, false);
compTab1.setLayout(gridLayout1);
"5" because you have 3 groups and 3 lines. if you have 4 groups and 3 lines change it to 7.
0
 

Author Comment

by:Tolgar
Comment Utility
Ok. Perfect! This works. One minor question. Even though I used black as a color for the separators, it shows up as white. Do you have any idea why?

This is the code I use:

        Label verticalSepartor32 = new Label(compTB3, SWT.SEPARATOR | SWT.SHADOW_OUT | SWT.VERTICAL);
        GridData sepGD32 = new GridData(GridData.FILL_VERTICAL);
        verticalSepartor32.setLayoutData(sepGD32); verticalSepartor32.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));

Open in new window

0
 
LVL 16

Accepted Solution

by:
Valeri earned 500 total points
Comment Utility
actually it's the shadow of the separator which always white. my mistake. in the above code just replace "SWT.SHADOW_OUT" with "SWT.SHADOW_NONE"
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

744 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

16 Experts available now in Live!

Get 1:1 Help Now