Solved

How to give color to toolbar borders in SWT?

Posted on 2013-06-18
3
397 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
[X]
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
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
The viewer will learn how to implement Singleton Design Pattern in Java.
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.
Suggested Courses

627 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