JDK-8216507 : StyleablePropertyFactory: example in class javadoc does not compile
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: openjfx11,openjfx12
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-01-10
  • Updated: 2023-01-12
  • Resolved: 2023-01-04
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.
Other
openjfx20 b14Fixed
Related Reports
Relates :  
Description
it's the 3. example, offending line:

private final StyleableProperty<Boolean> selected =
         new SimpleStyleableBooleanProperty(this, "selected", "my-selected");

error: the constructor (...) is undefined

The first parameter needs to be of type CssMetaData.

javadoc: 
https://openjfx.io/javadoc/11/javafx.graphics/javafx/css/StyleablePropertyFactory.html

Comments
Changeset: 94fb7ede Author: Karthik P K <kpk@openjdk.org> Committer: Andy Goryachev <angorya@openjdk.org> Date: 2023-01-04 16:33:43 +0000 URL: https://git.openjdk.org/jfx/commit/94fb7ede2dcde306a631d1feb0107c96a8221452
04-01-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/983 Date: 2022-12-23 13:55:30 +0000
23-12-2022

As stated above, reopening since I don't know what the fix is.
13-02-2019

Yeah, I had other ideas on how to fix it. I will only fix it as part of JDK-8211014 if someone tells me what the correct fix is because I don't want to guess. If not, I'll reopen and let someone else handle it.
17-01-2019

yeah, it's weird - far from being an expert on css/styling I can only guess: could be the use-case if the property invalidation needs to have side-effects, like validation done in its validated, then it must be created manually vs. letting the factory handle it. Don't now what the creation of the metaData in the initialization block is doing .. My code would be something like: private static final StyleablePropertyFactory<MyButton2> FACTORY = new StyleablePropertyFactory<>(Button.getClassCssMetaData()) { { // not needed I guess - or is it? // createBooleanCssMetaData("-my-selected", s -> s.selected, false, false); } }; // StyleableProperty implementation reduced to one line private final StyleableProperty<Boolean> selected = // original line, doesn't compile // new SimpleStyleableBooleanProperty(this, "selected", "my-selected"); new SimpleStyleableBooleanProperty( FACTORY.createBooleanCssMetaData("-my-selected", s -> s.selected, false, false), this, "selected") { @Override protected void invalidated() { // do stuff, f.i. validation } }; maybe any of the css gurus might give it a look ...
17-01-2019

[~fastegal] I got to fixing this, but I don't really understand the point of the 3rd example. The factory calls a method in an initializer and does nothing with the return value. I can only guess what the intent was. Can you provide a correction?
16-01-2019

Thanks!
10-01-2019

Yes, Iv'e added it do the list.
10-01-2019

[~nlisker] Do you want to include this with your other fixes for JDK-8211014?
10-01-2019