Solved

How to create a check box in the toolbar in SWT?

Posted on 2013-06-11
4
547 Views
Last Modified: 2013-06-19
Hi,
How can I create a check box in the toolbar by using SWT?

I am sending an screen shot in the attachment to give a better idea?

Thanks,
check-box.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
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Valeri
ID: 39253540
the ToolItem could be of type check box. You can have a custom tool bar "Filtering", but the items should be in a row, not in a column.
In the previous code I have added for you one check box item in the first tab /the last one, the one with name item_2_3/. It is not real check box, but you can change the icon / icon checked | icon not checked /. This is the only way you can implement the check box in the tool bar. Click on "item_2_3". If you choose the right icon, then it's check box. for example see the eighth icon in Eclipse, it's like checkbox.

item12_111 = new ToolItem(custToolBar12.getToolBar(), SWT.CHECK);
0
 

Author Comment

by:Tolgar
ID: 39256415
I put the following lines for the checkbox.

        //3rd group
        CustomToolbar custToolBar333 = new CustomToolbar(compTB3, SWT.BORDER, "Filtering");
        
        item3333 = new ToolItem(custToolBar333.getToolBar(), SWT.CHECK);
        item3333.setImage(image_floppy_disk); item3333.setText("Filtering"); item3333.setToolTipText("Filter the results below");
        item3333.addListener(SWT.Selection, toolBarListener);

Open in new window


Obviously, I didn't you the right icon but when when I click on the icon it shows like selected but not like a check box. It's more like a selected button and not selected button.

How can I do it as it is in the attachment that I sent in the first post of this questions?
0
 
LVL 16

Accepted Solution

by:
Valeri earned 500 total points
ID: 39257975
I have created a custom component that meets the requirement from the picture. Add to the project the attached file. after that add to your toolbar an instance of the attached file in this way:
TICheckBoxes checkBoxes = new TICheckBoxes(compTB, SWT.FLAT);

for example after the last separator in the toolbar add this line. the same as CustomToolBar, and separators between tool groups, this class will represent the three checkboxes you want.
TICheckBoxes.java
0
 

Author Closing Comment

by:Tolgar
ID: 39260378
Perfect solution!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jsp insert to database example 2 61
running on tomcat not jboss eap 7.0 3 30
passing enum to a method 4 35
Java Inheritance super keyword use 8 36
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

749 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