DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2007

    GUI: add listener to treeItem

    Hi, i would like to add checkbox listener to my TreeItem instead to the whole tree (child having checkbox but parents dont) which i code as following:

    Tree tree = new Tree(shell, SWT.NULL);
    TreeItem itemI = new TreeItem(tree, SWT.NULL);
    TreeItem itemJ = new TreeItem(itemI, SWT.NULL);
    TreeItem itemK = new TreeItem(itemJ, SWT.BORDER |SWT.CHECK);

    itemK.addListener(SWT.Selection, new Listener() {
    public void handleEvent(Event event) {
    if (event.detail == SWT.CHECK && !ButtonClik) {
    TreeItem item = (TreeItem) event.item;
    boolean checked = item.getChecked();


    but...then outcome appears is all the nodes do not have check box..can someone help to see where is wrong??

  2. #2
    Join Date
    Dec 2004
    San Bernardino County, California
    What context tells you (or can tell you) that the TreeItem you are adding is a leaf? Can you test for that context and, if true, add the checkbox?

  3. #3
    Join Date
    Apr 2007
    how to check if it is a leaf and how to add check box? i mean can you give portion of code for me to refer?

  4. #4
    Join Date
    Dec 2004
    San Bernardino County, California
    I don't know enough about the widgets package to help you with this. I suspect that there is a reason why your "OR"ing of the style is not working and I expect that the reason is that there must be some context switch that allows the program to select one or the other Image which is not being checked or not being set.

    Here is a link to the JDocs site which provides access to all sorts of API documentations, including the SWT.

    Last edited by nspils; 09-12-2007 at 10:01 AM.

Similar Threads

  1. Replies: 8
    Last Post: 04-11-2006, 07:40 AM
  2. Replies: 2
    Last Post: 03-25-2006, 10:21 AM
  3. Can't add action listener
    By vxfox05 in forum Java
    Replies: 3
    Last Post: 04-29-2005, 07:04 PM
  4. Replies: 3
    Last Post: 03-06-2003, 05:26 AM
  5. Displaying XML Data using .Net Controls
    By Greg Rothlander in forum ASP.NET
    Replies: 1
    Last Post: 11-27-2001, 06:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.