Solved

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

Posted on 2013-06-11
9
349 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
  • 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

789 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