Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7577959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:19:01+00:00 2026-05-30T17:19:01+00:00

I want to implement a tree with checkable root nodes and some parameters (actually,

  • 0

I want to implement a tree with checkable root nodes and some parameters (actually, parameters in this case does not matter) inside. So, I make a Tree, then place there 2 columns, and after that place a TreeItem. Then I need to place a TreeEditor with checkbox-button Button button = new Button(tree, SWT.CHECK);

There is a problem: if the text in a TreeItem is not set (or is equal to “”), then on expanding a tree-node element, a small ractangle will be shown and will not be hidden. If the text is set to TreeItem, then rectangle will be shown around text in TreeItem, but it will hide if mouse moves out from TreeItem. Is there a way of not showing this rectangle?

Empty text area

Here are the sources:

Tree tree = new Tree(composite_1, SWT.NONE);
tree.setHeaderVisible(true);
tree.setLinesVisible(true);

TreeColumn trclmnProperty = new TreeColumn(tree, SWT.NONE);
trclmnProperty.setWidth(100);
trclmnProperty.setText(Messages.AppWindow_trclmnProperty_text);

TreeColumn trclmnValue = new TreeColumn(tree, SWT.NONE);
trclmnValue.setWidth(100);
trclmnValue.setText(Messages.AppWindow_trclmnValue_text);

// Reading contents of a tree
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
try {
    builder = factory.newDocumentBuilder();
    File f = new File("ftplist.xml");
    org.w3c.dom.Document doc = builder.parse(f);
    NodeList ftpList = doc.getElementsByTagName("ftp");

    for (int i = 0; i < ftpList.getLength(); i++) {
        NodeList nodeList = ((Element) ftpList.item(i)).getElementsByTagName("ftpName");
        TreeItem treeItemRootNode = new TreeItem(tree, SWT.NONE);

        TreeEditor treeRootNodeEditor = new TreeEditor(tree);

        final Button button = new Button(tree, SWT.CHECK);
        button.setText(nodeList.item(0).getTextContent());
        nodeList = ((Element) ftpList.item(0)).getElementsByTagName("ftpEnabled");
        button.setSelection(nodeList.item(0).getTextContent().equalsIgnoreCase("true"));

        button.pack();

        treeRootNodeEditor.minimumWidth = button.getSize().x;
        treeRootNodeEditor.horizontalAlignment = SWT.LEFT;

        treeRootNodeEditor.setEditor(button, treeItemRootNode, 0);

        nodeList = ((Element) ftpList.item(0)).getElementsByTagName("ftpHost");
        TreeItem treeItemFtpHost = new TreeItem(treeItemRootNode, SWT.NONE);
        treeItemFtpHost.setText(new String[] { "Host", nodeList.item(0).getTextContent() });
        }

    } catch (ParserConfigurationException e1) {
        e1.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

ftplist.xml – It is just a config file, contains just ftp-settings like host, port, etc.

ftplist.xml:

<?xml version="1.0"?>
<ftps>
    <ftp>
        <ftpName>SuperFtp</ftpName>
        <ftpEnabled>true</ftpEnabled>
        <ftpHost>ftp.com</ftpHost>
        <ftpPort>21</ftpPort>
        <ftpLogin>Login</ftpLogin>
        <ftpPassword>Pass</ftpPassword>
        <ftpUsePassiveMode>true</ftpUsePassiveMode>
        <ftpRemoteDir>/</ftpRemoteDir>
        <localSyncDir>C:/</localSyncDir>
    </ftp>
    <ftp>
        <ftpName>SuperFtp2</ftpName>
        <ftpEnabled>true</ftpEnabled>
        <ftpHost>ftp.com</ftpHost>
        <ftpPort>21</ftpPort>
        <ftpLogin>Login</ftpLogin>
        <ftpPassword>Pass</ftpPassword>
        <ftpUsePassiveMode>true</ftpUsePassiveMode>
        <ftpRemoteDir>/</ftpRemoteDir>
        <localSyncDir>C:/</localSyncDir>
    </ftp>
<ftps>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:19:02+00:00Added an answer on May 30, 2026 at 5:19 pm

    The following snippet should prevent your Tree from drawing its selection:

    tree.addListener(SWT.EraseItem, new Listener()
    {
      public void handleEvent(Event event)
      {
        if ((event.detail & SWT.SELECTED) != 0)
        {
          event.detail &= ~SWT.SELECTED;
        }
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to implement a bi-directional tree in a case class. This seems
given this class definition: public class Frame { IFrameStream CapturedFrom; } I want implement
i have question for example i want to implement binary tree with array i
I want to implement a simple SceneGraph in Haskell using Data.Tree consisting of Transform
I am trying to implement some tree like that in ASP.NET: alt text http://i.msdn.microsoft.com/w6ws38fw.vbVenusSiteNavigation_TreeView1(en-us,VS.100).gif
Going through some excercises to hone my binary tree skills, I decided to implement
I want to run some code on all my treeView nodes depending on a
I want to implement a Generic Tree in java and i want to use
For haskell practice I want to implement a game where students/pupils should learn some
I want to implement tree widget but it doesn't have to show the hierarchy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.