Does Java provide any extended default pack of icons usable for each Swing and JavaFX frameworks? I mean arrows, warnings, files, errors, notifications, shapes, hands..
I am aware of downloadable unofficial ones and easily to be imported. I ask if there some included within Swing or JavaFX do exist and if so, how to access them.
For example I'd like to use them as the icon of the item available in a ComboBox etc.
I have found this webpage dealing with a similar issue in Swing, however it doesn't fully answer my question, moreover I am looking for a JavaFX stuff as well.
OT: For ones who vote ths question to be closed as OT, I don't ask for any recommend tool, software library, tutorial or other off-site resource. I ask for the official one.
JavaFX answer
There are a lot of icons baked into JavaFX, but using them is not documented and not really the way to go, since it may change in the future.
But if you want to go down that route, you will first need to extract the JavaFX stylesheet modena.css which is described over here.
Now you will find all sorts of examples on how to use JavaFX CSS and two types of these built in icons:
-fx-shape-fx-graphicIf you picked a symbol and now want to use it, you have to reproduce the exact hierarchy with the exact same style classes to apply the same style.
Example for SVG: Let's say you are interested in the cross of .default-color3.chart-symbol
@Override
public void start(Stage pPrimaryStage) throws Exception
{
final StackPane graphic = new StackPane();
graphic.setMaxSize(25, 25);
graphic.getStyleClass().addAll("default-color3", "chart-symbol");
pPrimaryStage.setScene(new Scene(new BorderPane(graphic), 500, 500));
pPrimaryStage.show();
}
Example for a graphic: The HTML Editors cut icon:
@Override
public void start(Stage pPrimaryStage) throws Exception
{
final Label graphic = new Label();
graphic.getStyleClass().add("html-editor-cut");
pPrimaryStage.setScene(new Scene(new BorderPane(graphic), 500, 500));
pPrimaryStage.show();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With