[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

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

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
Tolgar
Asked:
Tolgar
  • 5
  • 4
1 Solution
 
ValeriCommented:
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
 
TolgarAuthor Commented:
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
 
ValeriCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
TolgarAuthor Commented:
Ok. I am waiting for your solution.

Thanks,
0
 
ValeriCommented:
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
 
TolgarAuthor Commented:
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
 
ValeriCommented:
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
 
TolgarAuthor Commented:
I opened the following question to ask one follow-up question.

http://www.experts-exchange.com/Programming/Languages/Java/Q_28160423.html
0
 
TolgarAuthor Commented:
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

Technology Partners: 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!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now