Solved

How to give color to toolbar borders in SWT?

Posted on 2013-06-18
3
353 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
ID: 39257944
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
ID: 39259979
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
ID: 39264108
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

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

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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…

863 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

20 Experts available now in Live!

Get 1:1 Help Now