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

Incompatible type in example code in TreePath

    XMLWordPrintable

Details

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

    Description

      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/

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported: