Forum Stats

  • 3,767,816 Users
  • 2,252,720 Discussions
  • 7,874,335 Comments

Discussions

SwiXml - Issue in providing checkbox for JTree nodes

User_6T1AO
User_6T1AO Member Posts: 246 Employee
edited Aug 16, 2013 3:28AM in Java Desktop Applications

Hi,

We are using SwiXml 1.5 to develop a UI. We are getting issue while displaying JTree with checkbox option. We found below url to achieve the same thing

http://www.java2s.com/Tutorial/Java/0240__Swing/CheckBoxTreenode.htm

We have customised the TreeTest.java class as per SwiXml

We have configured the XML with InitClass as below

<scrollpane id="ehdd_task_tree"> 

        <gridbagconstraints insets="5,5,5,5" gridx="1" gridy="1" weightx="1.0" 

                            weighty="1.0" fill="GridBagConstraints.BOTH" 

                            anchor="GridBagConstraints.WEST"/> 

        <tree id="ehdd_tree" initclass="com.oracle.appsfdoc.fusion.sos.TreeTest" Font="ARIAL-BOLD-14" VisibleRowCount="10" RootVisible="TRUE" ExpandsSelectedPaths="true"/> 

    </scrollpane>

Following is TreeTest.java

==========================

    public class TreeTest extends DefaultTreeModel  

    { 

     

      protected final static String[] questions = { "A","B","C" }; 

      DefaultMutableTreeNode root ; 

     

      public TreeTest() { 

        super(new DefaultMutableTreeNode ("ROOT")); 

          root = (DefaultMutableTreeNode)super.getRoot(); 

          JTree tree = new JTree( getRootNode() ) { 

          public boolean isPathEditable(TreePath path) { 

            Object comp = path.getLastPathComponent(); 

            if (comp instanceof DefaultMutableTreeNode) { 

              DefaultMutableTreeNode node = (DefaultMutableTreeNode) comp; 

              Object userObject = node.getUserObject(); 

              if (userObject instanceof TrueFalseTreeNodeData) { 

                return true; 

              } 

            } 

            return false; 

          } 

        }; 

        tree.setCellRenderer(new QuestionCellRenderer()); 

        tree.setCellEditor(new QuestionCellEditor()); 

        tree.setEditable(true); 

      } 

     

      protected MutableTreeNode getRootNode() { 

        DefaultMutableTreeNode child; 

        TrueFalseTreeNodeData question; 

        for (int i = 0; i < questions.length; i++) { 

          question = new TrueFalseTreeNodeData(questions[i]); 

          child = new DefaultMutableTreeNode(question); 

          root.add(child); 

        } 

        return root; 

      } 

    } 

We can find other required class files(QuestionCellRenderer/QuestionCellEditor/TrueFalseTreeNodeData) from the URL

http://www.java2s.com/Tutorial/Java/0240__Swing/CheckBoxTreenode.htm

We are successfully executed the jave program given in above URL. We are getting issue with our customization according SwiXml.

We are getting A=false,B=false,c=false under ROOT. Some how, could not able to provide checkbox for the subnodes of tree.

Please suggest, if Iam doing some thing wrong.

It would be really great help, if you can suggest on this.

Thanks,

Samba.

Answers

This discussion has been closed.