javafx 8 - Adding a custom component to SceneBuilder 2.0 -
i have need have selection listener , select method on pane able monitor , present highlight when node clicked on.
i did following:
public class panewithselectionlistener extends pane { private objectproperty<annotation> selectedannotation = new simpleobjectproperty<>(); public panewithselectionlistener() { super(); selectedannotation.addlistener((obs, oldanno, newanno) -> { if (oldanno != null) { oldanno.setstyle(""); } if (newanno != null) { newanno.setstyle("-fx-border-color: blue;-fx-border-insets: 5;-fx-border-width: 1;-fx-border-style: dashed;"); } }); setonmouseclicked(e->selectannotation(null)); } public void selectannotation(annotation ann){ selectedannotation.set(ann); }
}
and works great - not able work scenebuilder anymore since fxml references panewithselectionlistener rather pane. not sure how custom pane scenebuilder. have looked @ other questions , combination of fxml , controllers - pane.
does know of way this, or perhaps swap pane panewithselectionlistener @ initialization time?
thanks
if issue make custom class available in scenebuilder, can following steps:
- bundle custom class (and supporting classes, such
annotation
) jar file - in scenebuilder, activate drop-down button next "library" in top of left pane:
- choose "import jar/fxml file..."
- select jar file created step 1
- make sure class need access in scenebuilder (
panewithselectionlistener
) checked - press "import component"
panewithselectionlistener
appear in scenebuilder under "custom" in left pane:
you'll notice drop-down in scenebuilder has "custom library folder" option, can open folder jar files stored. quick option, can copy jar files folder , (after short delay), contained classes appear in "custom" list.
Comments
Post a Comment