Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8192960

Add more documentation examples to JavaFX TreeItem

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      A DESCRIPTION OF THE REQUEST :
      I ask here for an documentation improvement ( there is no bug in fact, but documentation is wrong ). I tried to create a TreeView with my own TreeItem.

      Following the instructions from:
      https://docs.oracle.com/javafx/2/api/javafx/scene/control/TreeItem.html
      I should return in getChildren() my own list of children objects.
      This does now work, it will show an empty node in the interface. It works only to put the children TreeItems in the super.getChildren(), since that collection already has listeners attached to it. Below is the code which worked fine.

      I would ask few more requirements:
      1. Improve documentation and show also how to create own custom component with CSS properties. I didn't find any good documentation for this.
      2. Add a texteditor with highlight capabilities and support for large files to default JavaFx. There is something on the free market, a Java supported one would be better.



      JUSTIFICATION :
      The code from the actual documentation does not work.


      ---------- BEGIN SOURCE ----------


      public class UnitTreeItem extends TreeItem<Unit> {

          private boolean isFirstTimeChildren = true;

          public UnitTreeItem(Unit unit ) {
              super(unit );
          }

          @Override
          public ObservableList<TreeItem<Unit>> getChildren() {
              if (isFirstTimeChildren) {
                  isFirstTimeChildren = false;
                  Unit unit = getValue();
                  final ObservableList<TreeItem<Unit>> ch = super.getChildren();
                  if (unit != null ) {
                      for ( Enumeration<Unit> en = unit.children(); en.hasMoreElements(); ){
                          Unit child = en.nextElement();
                          ch.add(new UnitTreeItem(child));
                      }
                  }
                  return ch;
              }
              return super.getChildren();
          }

          @Override
          public boolean isLeaf() {
              return getValue() == null || getValue().isLeaf();
          }


      }

      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              aghaisas Ajit Ghaisas
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: