Solved

How to give a name to a toolbar menu in SWT?

Posted on 2013-06-11
9
353 Views
Last Modified: 2013-06-19
Hi,
How can I give a name to a toolbar menu as shown in the attachment in word?

I circled the part in red in the attachment.

Thanks,
toolbar-name.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
  • 5
  • 4
9 Comments
 
LVL 16

Expert Comment

by:Valeri
ID: 39241267
it's possible only if a custom composition is created and this composition contains the coolBar at the top and Label with title you want at bottom. See attached files. Btw ToolBar is replaced with CoolBar. You can find more information about CoolBar in SWT API on I-net.
Gui.java
ToolBarListener.java
0
 

Author Comment

by:Tolgar
ID: 39242352
I did it for other tabs and it works fine. I have 2 small issues:

1- In this approach, the background color only shows up behind the icon but not the whole toolbar.

I am sending you a screen-shot in the attachment.

2- And also, the toolbar separator is different from the one I had before and it can be moved to left and right. How can I make it the same as before where I used to use the code below to make the separator:

new ToolItem(toolBar3, SWT.SEPARATOR);

Open in new window

icon-background-issue.png
toolbar-separator-before.png
toolbar-separator-issue.png
0
 
LVL 16

Expert Comment

by:Valeri
ID: 39244869
yes, you are right... this is because I used "CoolItem" insted of "ToolItem" in order to show name for the group of items in the tool bar... probably I have to rework the code to meet your requests 1 and 2. SWT doesn't offer name for a group of items in the tool bar.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:Tolgar
ID: 39245100
Ok. I am waiting for your solution.

Thanks,
0
 
LVL 16

Expert Comment

by:Valeri
ID: 39253490
Hi,
I have created CustomToolBar that meets your requirements. You have to remove from code all of the "Cool..." components. Once you have added the custom tool bar you need only to create the respective "ToolItem" 's.
first create the CustomToolBar /it's very simple, you can check teh code/. It should have as parent the respective Tab /tab 1, tab2/. Wen you create the ToolItem's they have to have as a parent the tool bar from CustomToolBar. you can refer to it by using .getToolBar() method.
that's all. see the attached files.
Gui.java
CustomToolBar.java
ToolBarListener.java
0
 

Author Comment

by:Tolgar
ID: 39254642
This is great! It works as I expected.

I have one minor question related to this. The background for the name of the toolbars is white. So when I give a color such as gray to the toolbar it looks white around the toolbar name.

How can I give a background color to the name of the toolbar so that it looks same as the toolbar? (Marked as red in the attachment)

And is it possible to remove the gab in between the toolbars. (Marked as blue in the attachment)

I am showing it in the attachment and marked the questions with blue and red circles.

Thanks a lot!
white-background-gap.png
0
 
LVL 16

Accepted Solution

by:
Valeri earned 500 total points
ID: 39255460
for the red note, you just need to add this line:
caption.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GREEN));
to the end of constructor of CustomToolBar, right after this line:
toolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GREEN));

for the blue note, you need to add all of the CustomToolBar's you have instantiated to another composition, and when you set the Layout of this composition, you have to set the horizontalSpacing to 0. See the attached file with the changes. The new code is Composition "compTB".
Gui.java
0
 

Author Comment

by:Tolgar
ID: 39256378
I opened the following question to ask one follow-up question.

http://www.experts-exchange.com/Programming/Languages/Java/Q_28160423.html
0
 

Author Comment

by:Tolgar
ID: 39256488
If you have time, I would appreciate if you can also look at this question related with the same GUI.

http://www.experts-exchange.com/Programming/Languages/Java/Q_28160455.html

Thanks,
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

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 75
Java basic valueOf question 1 47
running on tomcat not jboss eap 7.0 3 50
IBM TS2900 (3572) Tape Autoloader Java? 12 100
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
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…
Suggested Courses

738 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