CSS Styling for the NetBeans Platform

What's the difference between these two NetBeans Platform applications?

The difference between the two screenshots is that the second is styled by a stylesheet with this content:

.digital-clock {
    -fx-effect: dropshadow(two-pass-box , darkgray, 10, 0.0 , 4, 5);
}

The file containing the content above is named "digitalClock.css". The clock is a JavaFX component, in fact, one of the samples you get with NetBeans IDE. When the JavaFX Scene is created, the final line below sets the stylesheet above on the clock:

Platform.runLater(new Runnable() {
    @Override
    public void run() {
        Scene scene = new Scene(root);
        setScene(scene);
        scene.getStylesheets().add(DigitalClock.class.getResource("digitalClock.css").toExternalForm());
    }
});

Next, in the clock definition, notice the final statement below:

Clock clock = new Clock(Color.ORANGERED, Color.rgb(50, 50, 50));
clock.setLayoutX(45);
clock.setLayoutY(186);
clock.getTransforms().add(new Scale(0.83f, 0.83f, 0, 0));
clock.getStyleClass().setAll(DEFAULT_STYLE_CLASS);

The reference that you see above is defined as follows, pointing to the element you see in the CSS stylesheet above:

private static final String DEFAULT_STYLE_CLASS = "digital-clock";

Thanks to Toni for this article, which showed me the way to the code above. As a result, we can now style NetBeans Platform applications with CSS!

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today