Solved

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

Posted on 2013-06-11
9
342 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:Tolgar
Comment Utility
Ok. I am waiting for your solution.

Thanks,
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 16

Expert Comment

by:Valeri
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now