?
Solved

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

Posted on 2013-06-11
9
Medium Priority
?
358 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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 how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 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