Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to give color to toolbar borders in SWT?

Posted on 2013-06-18
3
363 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
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 arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

840 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