JDK-8144871 : Add default method getStyleableNode to Styleable interface
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: controls
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-12-07
  • Updated: 2016-01-05
  • Resolved: 2016-01-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Fixed
Related Reports
Relates :  
Description
See attached patch for suggested change, but at a high-level there currently exists impl_styleableGetNode() on four classes:

 * MenuItem
 * PopupControl
 * TableColumn
 * TreeTableColumn

The basic use case is that in these cases these classes are not Nodes, and therefore can not be used directly in places such as Scene Builder. Scene Builder therefore needs to query for the actual root styleable node. 
Comments
Changeset: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/ca3bdcd8e72d
05-01-2016

That looks good.
17-12-2015

Here is the updated JavaDoc I propose: + /** + * Returns the Node that represents this Styleable object. This method should be overridden + * in cases where the Styleable is not itself a Node, so that it may optionally + * return the relevant root node representation of itself. By default this method returns + * null, which can mean that either the Styleable itself is a Node, or if that is not + * the case, that the Styleable does not have a node representation available at the + * time of request. + * + * @since 9 + */ + default Node getStyleableNode() { + return null; + }
16-12-2015

I don't have strong feelings. Just wanted it to be a deliberate decision. getXXX it is. So other than an intro sentence in the docs, this should be ready to go.
10-12-2015

Having looked around I think we could argue for having this be a getter - there is enough precedence (e.g. Region.getUserAgentStylesheet). It depends on how strongly we are against using get...
10-12-2015

API looks good, although we may want a name that doesn't start with "get" since it isn't a property (although in this case the name you propose seems OK). The docs for the new method could use an initial sentence that describes the function of the method (e.g., "Returns the Stylable node that represents this object." or similar). Let me know your thoughts on the name.
09-12-2015

Patch ready for review.
08-12-2015