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

Incompatible type in example code in TreePath

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 19
    • 7
    • client-libs
    • b10
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      In the API under javax.swing.tree.TreePath there is a code example whose last assignment gives an error at compile time: "incompatible types" as getUserObject() returns an Object.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
         DefaultMutableTreeNode selectedNode =
             (DefaultMutableTreeNode)selectedPath.getLastPathComponent();
         Object myObject= selectedNode.getUserObject();

      ACTUAL -
         DefaultMutableTreeNode selectedNode =
             ((DefaultMutableTreeNode)selectedPath.getLastPathComponent()).
             getUserObject();

      URL OF FAULTY DOCUMENTATION :
      http://docs.oracle.com/javase/7/docs/api/

            psadhukhan Prasanta Sadhukhan
            mduigou Mike Duigou
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: