Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

SwiXml - Issue in providing checkbox for JTree nodes

Sambasivarao Medavarapu-OracleAug 15 2013 — edited Aug 16 2013

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.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 13 2013
Added on Aug 15 2013
1 comment
1,391 views