Rendering in JavaFX

Hi,
I am currently working on my bachelor thesis about JavaFX 2
I have a few questions about rendering in JavaFX
I don’t really understand what the glass toolkit is for and how it’s connected to prism.
If the glass toolkit is firing the pulse event how does prism know that it has to render a frame?
And how does the Quantum Toolkit handling the threads?
And what is the advantage of having two threads (Application and Prism Render Thread) instead of one like in Swing?
I haven’t found much about rendering in the documentation so please help me. :)

Hi David,
Glass is to FX as AWT is to JavaSE. Sort of :-). Glass is our windowing toolkit implementation. It is responsible for showing windows (including Stage, Popup, etc), managing the event queue, passing events up to JavaFX, and setting up timers. Every native application (on Windows, Mac, Linux, etc) has a native event queue. On some platforms like Mac, you get callbacks called whenever an event needs to be handled (that is, the native system pumps the event queue and delivers events to native callback methods). So on Mac Glass, we get these native callbacks, turn them in to JavaFX events, and send them to JavaFX (more or less). On Windows we have to manually pump the event queue, pulling off the event, creating the JavaFX event equivalent, and then pass that up to JavaFX for dispatching.
Pulse events are normal events on our event queue, but they are generated based on a timer. Glass sets up a timer which fires off every 16.666ms. It is either based on just a hi resolution system timer (native), or it is based on a callback from the OS whenever the video card refresh occurs. This latter mechanism is much more precise, system timers can sometimes drift leading to "jitter" in animations whereas the video card refresh is pretty rock solid. When JavaFX gets notified by glass when the timer fires, it checks to see: is there a pulse already queued up or being handled? If so, don't fire another pulse (keeps us from flooding the event queue with pulses). If the scene is not dirty and there are no animations, then we don't need to handle the pulse. Otherwise if the scene is clean but there are animations, then we handle the pulse. A PulseEvent is then created and put on the event queue.
During the normal process of handling the events on the event queue, when we encounter a pulse event, we then do the following things:
- Process animations
- Process CSS
- Process Layout
- Synchronize from the FX scene graph to the render tree (Prism)
- Pick the scene and update the mouse hover state if a node has moved under the cursor or moved out from under the cursor
The render thread then goes off and renders after the synchronization step has occurred.
Quantum is the thing that listens to Glass pulse timer events and creates the PulseEvent and adds it to the event queue, and is also the thing that handles the pulse event, causing animations to be processed and then telling each scene to handle the pulse event (where each scene processes CSS, layout, and synchronizes etc). Quantum then tells the render thread to go off and render.
Presently in JavaFX, although we have a render thread and application thread, they both essentially run synchronous. I have a patch going into 3.0 as soon as the repo opens that allows us to run multithreaded, where the FX app thread and render thread will be running in parallel except for the brief period of time where they synchronize during the pulse. We have seen 1.5x - 2x performance improvement on tablets by running these threads in parallel. We've also noticed 40%+ performance improvement on desktop in some of the scenarios I've run thus far. Having multiple threads just makes sense in a world where we have multiple cores (even on embedded systems!). Even on a single core, multiple threads might still be advantageous because the CPU doesn't have to wait on memory read operations or GPU operations but can be busy computing the state for the next rendered frame. Having multiple threads does increase the memory overhead, but actually it may not do so very significantly (we have one prototype where we found that the performance cost in constantly converting from FX Color to native Color objects was so bad that caching the converted color object was cheaper anyway, so it isn't clear that even in an immediate-mode style single-threaded rendering system that you'd save much in terms of memory).
I don't know when your thesis is due by, unfortunately a lot of code in this area hasn't been open sourced yet so you're kind of flying blind. May the decompiler ever guide you ;-)

Similar Messages

  • OffScreen rendering with JavaFX

    Hello,
    is there a way to render JavaFX to a user-supplied offscreen bufferedImage and be notified when the rendering happens ?
    is it possible to frame-step JavaFX by supplying used-defined timers ?
    Cheers,
    Mik
    --

    Many thanks,
    this is a quick way to take a screenshot.
    At the same time we really miss something (an offscreen canvas ?) where the JavaFX output can be redirected.
    Imagine you want to use JavaFX inside an OpenGL texture and have it updated frame by frame in synch with your timers.
    Also imagine you want to blend lightweight JavaFX scenes on top of normal Swing components.
    I think that this is a missing feature of JavaFX. It's kind of show-stopper for us.
    Cheers,
    Mik

  • Java 3D enables 3D rendering in JavaFX

    Hi,
    first attempts are being discussed in Java 3D forum at [http://forums.java.net/jive/thread.jspa?threadID=56033&tstart=0] .
    August
    Edited by: InteractiveMesh on Jan 26, 2009 8:38 AM

    Not being amiliar with that software package I can not be specific but it may be worth trying...
    Drop an ActiveX container on you FP.
    Right-click and try navigating to something that looks like the software you are after. You may have to poke around or create it from file or whatever...
    But if the software in ActiveX enabeld, it may just work.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Profiling JavaFX rendering

    I have written a small tool for profiling the rendering of JavaFX Script application
    Read about it in my blog:
    [http://www.nobel-joergensen.com/roller/java/entry/profiling_javafx_rendering]
    Please let me know what you think :-)
    - Morten Nobel
    Edited by: Mortennobel on Aug 3, 2008 2:09 AM

    I don't use NetBeans, but I had some success in profiling memory of a (standalone) JavaFX program with VisualVM, if it can help.

  • Complex (Indian) scripts not rendering in latest build of Jdk8

    Complex (Indian) scripts not rendering in JavaFx Text components of latest build of JDK8.
    I am using early access build b89 .
    I remember it was working in earlier JDK8 release when the button components were not bigger.

    You should probably post this in the 'Oracle Connector for Outlook' discussion forum for an appropriate response:
    Connector for Outlook
    OTN

  • JavaFX Documentation Ideas that Need Solutions

    Recently, the JavaFX documentation team has asked for ideas. The present documentation is superb but not complete. I'd still very much once and for all like to see the graphic dragons that were brought to light on the following link conquered.
    http://tiainen.sertik.net/2010/04/isometric-tile-rendering-in-javafx.html
    On this link from the days of yore (JavaFX 1.3) the knights of the JavaFX round table where having great difficulty rendering large scenegraphs and in the main article and also comments much discussion ensued.
    For me the question remains, how do I take a model with my data and render only the regions and data bits that need to be rendered in the graphic viewport? So, rendering specific regions is important plus not creating a zillion nodes to do it are both important issues to resolve. An example is a musical score where there is a large score but only the visible portion should be rendered at a readable zoom level and musical symbols should be resuable if at all possible.
    I know there are ways to hack this but I'm wondering if JavaFX now has programmatic techniques for the cases mentioned on the link above or the musical score scenario (besides just the speed factor with Prism)? Maybe a score could borrow concepts from the new cell factory based list components? Except a music score can implement cell factory and nodes representing musical symbols can be the reusable cells?
    I'd like to see an article on graphic strategies to use when the data model is large and outside of the scenegraph. Do cell factory techniques apply or not? Do other techniques from the link apply?
    Please write more about how this graphic dragon can be vanquished, thank you.

    I dont think so you can do it that way..

  • Calling a function from another class - help!

    I realize that this is probably a basic thing for people who have been working with JavaFX for a while, but it is eluding me, and I have been working on it for over a week.
    I need to call a function that is in another class.  Here's the deal.  In EntryDisplayController.java, there are 2 possible passwords that can be accepted - one will give full access to the car, the second will limit functions on the car.  So when a password is entered and verified as to which one it is, I need to call a function in MainDisplayController.java to set a variable that will let the system know which password is being used - full or restricted.
    So in MainDisplayController.java I have this snippet to see
    public class MainDisplayController implements Initializable, ControlledScreen {
        ScreensController myController;
        public static char restrict;
         * Initializes the controller class.
        @Override
        public void initialize(URL url, ResourceBundle rb) {
            // TODO
        public void setRestriction(){
            restrict = 0;
            restrictLabel.setText("RESTRICTED");
        public void clearRestriction(){
            restrict = 1;
            restrictLabel.setText("");
    And in EntryScreenDisplay.java I have this snippet:
    public class EntryDisplayController implements Initializable, ControlledScreen {
         @FXML
        private Label passwordLabel ;
        static String password = new String();
        static String pwd = new String("");
         ScreensController myController;
         private MainDisplayController controller2;
         * Initializes the controller class.
        @Override
        public void initialize(URL url, ResourceBundle rb) {
            setPW(pwd);    // TODO
         @FXML
        private void goToMainDisplay(ActionEvent event){
            if(password.equals ("123456")){
              controller2.clearRestriction();
               myController.setScreen(ScreensFramework.MainDisplayID);
               pwd = "";
               password = "";
               setPW(pwd);
            else if(password.equals ("123457")){
               controller2.setRestriction();
                myController.setScreen(ScreensFramework.MainDisplayID);
               pwd = "";
               password = "";
               setPW(pwd);
            else{
                password = "";
                pwd = "";
                setPW(pwd);
    When I enter the restricted (or full) password, I get a long list of errors, ending with
    Caused by: java.lang.NullPointerException
      at velocesdisplay.EntryDisplayController.goToMainDisplay(EntryDisplayController.java:60)
    Line 60 is where "controller2.setRestriction(); is.
    As always, thanks for any help.
    Kind regards,
    David

    You never set the controller2 variable to anything, which is why you get a null pointer exception when you try to reference it.
    public static variables (and even singletons) are rarely a good idea as they introduce global state (sometimes they can be, but usually not).
    If a static recorder like this can only have a binary value, use a boolean, if it can have multiple values, use an enum.
    Some of the data sharing solutions in dependency injection - Passing Parameters JavaFX FXML - Stack Overflow might be more appropriate.
    I also created a small framework for roll based solutions in JavaFX which perhaps might be useful:
    http://stackoverflow.com/questions/19666982/is-there-a-way-to-implement-a-property-like-rendered-on-javafx
    https://gist.github.com/jewelsea/7229260
    It was just something I hacked together, so it's not a fully polished solution and you probably don't need something quite so complex.
    What you need is a model class shared between the components of your application.  Dependency injection frameworks such as afterburner.fx can help achieve this in a fairly simple to use way.
    If you don't want to go with a dependency injection framework, then you could use either a static singleton model class for your settings or pass the model class using the mechanism in defined in the passing parameters link I provided.  For a model class example, see the ClickCounter class from this example.   That example doesn't use FXML, but to put it together with the passing parameters solution, for your restriction model, you would have something like the following:
       private class Restricted {
         private final ReadOnlyBooleanWrapper restricted;
         public Restricted(boolen isRestricted) {
           restricted = new ReadOnlyBooleanWrapper(isRestricted);  
         public boolean isRestricted() {
           return restricted.get();
         public ReadOnlyBooleanProperty restrictedProperty() {
           return restricted.getReadOnlyProperty();
    Then in your EntryDisplayController you have:
    @FXML
    public void goToMainDisplay(ActionEvent event) {
         // determine the restriction model as per your original code...
         RestictionModel restrictionModel = new RestrictionModel(<appropriate value>);
      FXMLLoader loader = new FXMLLoader(
      getClass().getResource(
       "mainDisplay.fxml"
      Stage stage = new Stage(StageStyle.DECORATED);
      stage.setScene(
       new Scene(
         (Pane) loader.load()
      MainDisplayController controller =
        loader.<MainDisplayController>getController();
      controller.initRestrictionModel(restrictionModel);
      stage.show();
    class MainDisplayController() {
      @FXML private RestrictionModel restrictionModel;
      @FXML private RestrictLabel restrictLabel;
      public void initialize() {}
      // naming convention (if the restriction model should only be set once per controller, call the method init, otherwise call it set).
      public void initRestrictionModel(RestrictionModel restrictionModel) {
        this.restrictionModel = restrictionModel;
         // take some action based on the new restriction model, for example
        restrictLabel.textProperty.bind(
          restrictionModel.restrictedProperty().asString()
    If you have a centralized controller for your navigation and instantiation of your FXML (like in this small FXML navigation framework), then you can handle the setting of restrictions on new screens centrally within the framework at the point where it loads up FXML or navigates to a screen (it seems like you might already have something like this with your ScreensController class).
    If you do this kind of stuff a lot, then you would probably benefit from a move to a framework like afterburner.  If it is just a few times within your application, then perhaps something like the above outline will give you enough guidance to implement a custom solution.

  • Search Box css problem in Ensemble2 with Win Xp

    Hi guys,
    I've notice a problem in style of search box in ensemble example. When the search box get the focus, the blue selection has not round corner as you can see here:
    http://justpaste.it/1h61
    This problem is present also in Windows Xp sp3. Why there is this difference between Win 7 and WIn xp?
    Thanks very much!

    Have some performance issues on Windows XP, too.
    I am using d3d prism settings to render on Windows 7 and XP. On Windows 7 everything working fine.
    On Windows XP it is slow and sometimes flickering.
    I didn't find a solution.
    1) Tried to start the application with other prism settings like -Dprism.order=d2d and OpenGL.
    2) I changed the 3d graphic settings that made it better, but didn't solve the issue.
    Someone knows the difference of rendering the javafx application in Windows 7 and XP (DirectX 11, DirectX9.0c)?

  • Strange behaviour on preloading web page in WebView

    I have the following problem: In my Swing application i'd like to show a web page. In order to do so i use a JFXPanel that contains a WebView. The web page should be loaded in the background and just if the loading process is totally completed i want to make the JFXPanel visible. I use the getLoadWorker().workDoneProperty() method of the corresponding WebEngine to determine if the page is totally loaded.
    The problem is, that at the moment the JFXPanel gets visibile I see at first a totally empty panel, and only after a short time the web page in the WebView is visible. I have made a simple Demo Application that reproduces this behaviour. If the page is loaded a button gets enabled and a click on that button adds the WebView to the panel below. Furthermore the following link points to an animated gif which demonstrates the behaviour: http://tinypic.com/view.php?pic=oh66bl&s=5#.Ujv2IhddWKl
    Here is the code of the demo application:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javafx.application.Platform;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.embed.swing.JFXPanel;
    import javafx.scene.Scene;
    import javafx.scene.web.WebEngine;
    import javafx.scene.web.WebView;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    public class WebViewTest extends javax.swing.JPanel {
       private static JFXPanel browserFxPanel;
       private WebView webView;
       private WebEngine eng;
      * Creates new form WebViewTest
       public WebViewTest() {
      initComponents();
       Platform.setImplicitExit(false);
      browserFxPanel = new JFXPanel();
       Platform.runLater(new Runnable() {
       public void run() {
      webView = createBrowser();
       Scene scene = new Scene(webView);
      scene.setFill(null);
      browserFxPanel.setScene(
      scene);
      * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The
      * content of this method is always regenerated by the Form Editor.
       @SuppressWarnings("unchecked")
       // <editor-fold defaultstate="collapsed" desc="Generated Code"> 
       private void initComponents() {
      java.awt.GridBagConstraints gridBagConstraints;
      pnlMain = new javax.swing.JPanel();
      showWebpageButton = new javax.swing.JButton();
      setLayout(new java.awt.GridBagLayout());
      pnlMain.setLayout(new java.awt.BorderLayout());
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 0;
      gridBagConstraints.gridy = 1;
      gridBagConstraints.gridwidth = 3;
      gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
      gridBagConstraints.weightx = 1.0;
      gridBagConstraints.weighty = 1.0;
      add(pnlMain, gridBagConstraints);
      showWebpageButton.setText("show web page");
      showWebpageButton.setEnabled(false);
      showWebpageButton.addActionListener(new java.awt.event.ActionListener() {
       public void actionPerformed(java.awt.event.ActionEvent evt) {
      showWebpageButtonActionPerformed(evt);
      gridBagConstraints = new java.awt.GridBagConstraints();
      gridBagConstraints.gridx = 1;
      gridBagConstraints.gridy = 0;
      gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
      add(showWebpageButton, gridBagConstraints);
       }// </editor-fold> 
       private void showWebpageButtonActionPerformed(java.awt.event.ActionEvent evt) {  
      pnlMain.removeAll();
      pnlMain.add(browserFxPanel, BorderLayout.CENTER);
       WebViewTest.this.invalidate();
       WebViewTest.this.revalidate();
       // Variables declaration - do not modify 
       private javax.swing.JPanel pnlMain;
       private javax.swing.JButton showWebpageButton;
       // End of variables declaration 
       private WebView createBrowser() {
       Double widthDouble = pnlMain.getSize().getWidth();
       Double heightDouble = pnlMain.getSize().getHeight();
       final WebView view = new WebView();
      view.setMinSize(widthDouble, heightDouble);
      view.setPrefSize(widthDouble, heightDouble);
      eng = view.getEngine();
      eng.load("http://todomvc.com/architecture-examples/angularjs/#/");
      eng.getLoadWorker().workDoneProperty().addListener(new ChangeListener<Number>() {
       public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
       final double workDone = eng.getLoadWorker().getWorkDone();
       final double totalWork = eng.getLoadWorker().getTotalWork();
       if (workDone == totalWork) {
      showWebpageButton.setEnabled(true);
       return view;
       public static void main(String[] args) {
       SwingUtilities.invokeLater(new Runnable() {
       public void run() {
       final JFrame f = new JFrame("Navigator Dummy");
      f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      f.setSize(new Dimension(1024, 800));
       final WebViewTest navDummy = new WebViewTest();
      f.getContentPane().add(navDummy);
      f.setVisible(true);
    I don''t understand this behaviour in fact that the page should already been loaded. For mee it seems like the WebView starts renderering the site just at the moment when it gets visible. What can I do to achieve that the WebView already shows the loaded web page at the moment it gets Visible (to avoid this flickr effect)?
    I have already posted this issue at StackOverflow (see http://stackoverflow.com/questions/18873315/javafx-webview-loading-page-in-background ) but didn't get an answer there and found this forum today.
    Thanks in advance!

    Try the updated version in this post.
    It forces an offscreen snapshot before displaying the webview to ensure all of the rendering is done before the WebView is displayed.
    The code is kind of ugly and the "solution" is a bit of a hack, you would probably want to clean it up a bit before using it anywhere (for example it is unnecessary to create a new WebView and snapshot the web page on every load - I just did that to get a feel for a worst case scenario and to try to pinpoint where slowdowns are occurring).
    A small rectangle moves back and forth across the top of the screen so that animation smoothness can be monitored.
    On the first load there will be a slight stutter in the animation, however the rendered web page appears instantly when the clicks the "Show page" button.
    As you say, the stutter only occurs the first time the page is loaded, subsequently everything is smooth.  If you use a regular progress bar rather than an animation, then the initial stutter is likely fine, as people expect to see pauses in progress bars from time to time (most progress reported by progress bars isn't a smooth linear progression).  My guess is that, if you use a regular progress bar, the behaviour experienced with this sample is likely acceptable to almost all users.
    Regarding the differences between rendering between JavaFX 2.2 and JavaFX 8, there were many modifications to the internal JavaFX architecture for JavaFX 8 that improved the rendering performance, so that likely accounts for the delta.
    import javafx.animation.*;
    import javafx.application.Application;
    import javafx.concurrent.Worker;
    import javafx.geometry.*;
    import javafx.scene.Scene;
    import javafx.scene.control.*;
    import javafx.scene.layout.*;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.web.WebView;
    import javafx.stage.Stage;
    import javafx.util.Duration;
    public class WebViewJavaFXTest extends Application {
        public static final String PAGE_URL = "http://todomvc.com/architecture-examples/angularjs/#/";
        private Rectangle distractor;
        @Override
        public void start(Stage stage) throws Exception {
            distractor = new Rectangle(20, 20, Color.CORAL);
            TranslateTransition r = new TranslateTransition(Duration.seconds(10), distractor);
            r.setFromX(0);
            r.setToX(800);
            r.setInterpolator(Interpolator.LINEAR);
            r.setCycleCount(RotateTransition.INDEFINITE);
            r.setAutoReverse(true);
            r.play();
            VBox layout = initView();
            stage.setScene(new Scene(layout));
            stage.show();
        private VBox initView() {
            final ProgressBar progress = new ProgressBar();
            final Button showWebView = new Button("Show Page");
            showWebView.setDisable(true);
            HBox controls = new HBox(
                    10,
                    progress,
                    showWebView
            controls.setAlignment(Pos.CENTER_LEFT);
            Button tryAgain = new Button("Try Again");
            tryAgain.setOnAction(actionEvent ->
                    tryAgain.getScene().setRoot(
                            initView()
            StackPane webViewHolder = new StackPane();
            webViewHolder.setPrefSize(1024, 700);
            final WebView webView = new WebView();
            progress.progressProperty().bind(
                    webView.getEngine().getLoadWorker().progressProperty()
            webView.setPrefSize(1024, 700);
            webView.getEngine().load(PAGE_URL);
            webView.getEngine().getLoadWorker().stateProperty().addListener(
                    (o, old, state) -> {
                        if (state == Worker.State.SUCCEEDED) {
                            webView.snapshot(
                                    snapshotResult -> {
                                        showWebView.setDisable(false);
                                        return null;
                                    null,
                                    null
                        } else {
                            showWebView.setDisable(true);
            showWebView.setOnAction(actionEvent -> {
                controls.getChildren().setAll(
                        tryAgain
                webViewHolder.getChildren().setAll(webView);
            VBox layout = new VBox(
                    10,
                    distractor,
                    controls,
                    webViewHolder
            layout.setPadding(new Insets(10));
            return layout;
        public static void main(String[] args) {
            launch();

  • Problems displaying fonts

    Hello.
    I am developing my first application using JavaFX 2.2 and I am not able to get a good visualization of the texts. The majority of texts in the application are displayed using Label controls, and I have read that, since Javafx 2.1, font rendering has been improved, including anti-aliasing and subpixel LCD treatment. However, I see some problems in my fonts, like wrong letter glyphs, unexpected colors etc.
    As Linux is my execution environment, I have tried to configure fonts in the system through Gnome options, but it does not seem to affect to the application. I have also checked that my FreeType version is quite modern and I have changed the configuration of the fonts.conf, but neither it worked.
    I have tested some JVM parameters, like -Dawt.useSystemAAFontSettings, but it only works if the graphical aceleration is disabled, so it is not a solution for me.
    The only thing that I can configure and seems to affect to the application is the antialiasing level in the NVidia controls, but it has the drawback that the smoothing is lost and the overall result is even worse.
    The operating system is a RHEL 6.2 and the grhaphic card an NVidia Quadro 2000D. The JavaFX version I am using is the 2.2 Developer Preview b19 and the fonts in the application are Arial and Consolas.
    As I have read in the JavaFX documentation, although with Text you can make some adjustments regarding fonts, that is not the case when using Label.
    Is it possible to change the configuration of fonts rendering in JavaFX to improve the visualization? How?
    Thanks.
    Regards.
    Edited by: vshorreo on 16-ago-2012 23:55

    I have also tested the application in some PCs with Windows and the visualization problems are significantly lower.
    Regards.

  • CSS Box Problem

    Hi,
    My site have a some problem in css box. Screen shot is attached for reference.
    Please help for the same.
    Weblink

    Have some performance issues on Windows XP, too.
    I am using d3d prism settings to render on Windows 7 and XP. On Windows 7 everything working fine.
    On Windows XP it is slow and sometimes flickering.
    I didn't find a solution.
    1) Tried to start the application with other prism settings like -Dprism.order=d2d and OpenGL.
    2) I changed the 3d graphic settings that made it better, but didn't solve the issue.
    Someone knows the difference of rendering the javafx application in Windows 7 and XP (DirectX 11, DirectX9.0c)?

  • Correct "clip" for background with round border

    Hi all. I'm having a problem with a round border and a round background. If you look at the code below you will see that I have a border specified with a radius of 5. If I run this, the background sticks outside of the border. If I also set the background to have a radius of 5, it still doesn't look correct as the outside of the border turns purple whereas I would expect it to be light red. If I change the background radius to 4 then the inside of the border doesn't quite match up to the background.
    How do I set a border and just say the background should be "clipped" by it?
    Thanks, Nick.
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.layout.FlowPane;
    import javafx.stage.Stage;
    public class RoundTest extends Application {
        @Override
        public void start(Stage stage) throws Exception {
            FlowPane flowPane = new FlowPane();
            Scene scene = new Scene(flowPane, 500, 500);
            flowPane.setStyle("-fx-padding: 10;");
            Label label = new Label("Hello");
            label.setStyle("-fx-border-color: red; -fx-border-radius: 5; -fx-background-color: blue;");
    //        label.setStyle("-fx-border-color: red; -fx-border-radius: 5; -fx-background-color: blue; -fx-background-radius: 5;");
            flowPane.getChildren().add(label);
            stage.setScene(scene);
            stage.show();
        public static void main(String[] args) {
            launch(args);
    }

    This is actually a kind of tricky question to answer well.
    The standard caspian.css stylesheet for JavaFX 2.2 makes almost no use of borders.
    The standard caspian controls have things that look like borders or highlighted edges, but these are almost always implemented by layered backgrounds.
    For instance a focus ring around a button is a blue background which is layered underneath the button background, making the ring look like a border, even though it's not.
    I don't really know why the layered background approach was chosen over a border + background approach. Possible reasons are:
    - it's easier.
    - it performs better.
    - it provides a better visual experience.
    Maybe it is one or all of the above.
    Regardless, I think there was likely some good reason why the layered background approach was chosen, so you'd probably best stick to it.
    One advantage of using this approach is there are lots of similar examples in caspian.css that you can copy from and use.
    A sample css style string for your sample app using layered borders, might be something like:
    -fx-padding: 1;  -fx-background-insets: 0, 1;  -fx-background-radius: 5, 5;  -fx-background-color: firebrick, forestgreen;By playing around with combinations of layered backgrounds, padding and background-insets you can achieve, borders around your controls which can be either entirely enclosed within your control's standard layout or outside of it (like the focus ring), so that when you add something like a focus ring around your control it doesn't shift the control's onscreen position - it really just surrounds the control.
    An updated version of your sample app which uses this is below:
    import javafx.application.Application;
    import javafx.scene.*;
    import javafx.scene.control.Label;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    public class RoundTest extends Application {
      @Override public void start(Stage stage) throws Exception {
    //    System.setProperty("prism.lcdtext", "false");
        StackPane stackPane = new StackPane();
        Scene scene = new Scene(stackPane, 500, 500, true);
        stackPane.setStyle(
            "-fx-background-color: cornsilk;"
          + " -fx-border-insets: 10;"
          + " -fx-border-color: rgba(128, 128, 128, 0.5)"
        Label label = new Label("Hello");
        label.setStyle(
    //        "-fx-padding: 5;"
    //      + " -fx-background-insets: 0, 5;"
    //      + " -fx-background-radius: 5, 5;"
            "-fx-padding: 1;"
          + " -fx-background-insets: 0, 1;"
          + " -fx-background-radius: 5, 5;"
          + " -fx-background-color: firebrick, forestgreen;"
          + " -fx-text-fill: whitesmoke;"
    //    label.setScaleX(5);
    //    label.setScaleY(5);
        stackPane.getChildren().add(new Group(label));
        stage.setScene(scene);
        scene.setCamera(new PerspectiveCamera());
        stage.show();
      public static void main(String[] args) { launch(args); }
    }Now for some other questions you raise:
    If I run this, the background sticks outside of the borderYeah the background radius and border radius properties are independent, so if you use a rounded border, you also need to use a rounded background or the background will overflow the border corners.
    If I also set the background to have a radius of 5, it still doesn't look correct as the outside of the border turns purple whereas I would expect it to be light redJavaFX 2.2 uses anti-aliasing in pretty much all of it's rendering (and even another trick for lcd called sub-pixel rendering of text in some cases). Your border is only one pixel wide. If the border isn't sitting exactly on a pixel boundary, it's going to be blended with the background. Even if the straight sides of the border sit exactly on the pixel boundary, when the border turns the corners, the anti-aliasing algorithms will kick in blending the border corner and the background around the inside edge of the corner.
    You chose a green background and a red border. When you mix those two colors, you get purple (which is what is happening).
    I don't know of anyway to enable or disable anti-aliased rendering for JavaFX scene graph objects (perhaps something to do that might come along for the ride with the 3D scene graph support in Java 8).
    Regardless, you probably want anti-aliasing engaged for your rendering anyway. So you should develop your app knowing that anti-aliasing will happen. To do this, choose colors which blend well when anti-aliased. Caspian does this by deriving a lot of the outer background colors from the inner background colors (i.e. just lightening or darkening the border). This works well because they have the same base rgb component mixture, just in different portions, so the anti-aliasing mixes them seamlessly. Choosing full colors at opposite ends of the rgb spectrum such as red and blue result in jarring mixtures like purple. Even if the anti-aliasing wasn't involved, your eyes can play tricks on you and have difficulty clearly seeing the border between these kind of colors due to the weird optics of the eyes.
    Another strategy to alleviate nasty blending is to use more pixels, e.g. instead of a one pixel border, use a two pixel border - the anti-aliasing blending will be far less noticeable. Using the greater pixel strategy works very well in conjunction with newer higher resolution screens (so called retina displays), where the pixels themselves are so small that the human eye is unable to distinguish the pixels and the way they blend.
    All that said - your original example with the rounded borders and background doesn't look too bad to me :-)
    One other issue I came across when testing this is that there is a -fx-border-style css attribute which can have values of centered, inside and outside, and when I tried to set it I got messages like:
    WARNING: com.sun.javafx.css.parser.CSSParser declaration CSS Error parsing in-line style '-fx-padding: 1; -fx-background-insets: 0, 1; -fx-background-radius: 5, 5; -fx-background-color: firebrick, forestgreen; -fx-border-style: inside; -fx-text-fill: whitesmoke;' from javafx.scene.Node$22@1bd5d8ab: Unsupported <border-style> 'inside' while parsing '-fx-border-style' at [1,138]
    The css reference guide notes that the border functionality copies from the w3c backgrounds and border functionality, but there is no inside, outside, centered border style in the w3c css reference, so I guess there is some error in the JavaFX 2 css documentation there around what is supported and what is implemented from the w3c css reference. Note that I'm not really advocating that the JavaFX css processing should match the w3c css reference as I find the w3c system complicated and difficult to understand.
    http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#region
    http://www.w3.org/TR/css3-background/#border-style
    Perhaps as borders in css don't seem to be used much in JavaFX, the documentation issue isn't such a big one.

  • Show tooltip on color list

    Is it possibile to show a tooltip to display the color name?
    http://s10.postimg.org/94rd93scp/Z034.png
    Here is my code for ComboBox color rendering
    import javafx.application.Application;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.scene.Scene;
    import javafx.scene.control.ComboBox;
    import javafx.scene.control.ContentDisplay;
    import javafx.scene.control.ListCell;
    import javafx.scene.control.ListView;
    import javafx.scene.layout.StackPane;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Rectangle;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    public class ProvaComboRendering extends Application {
        @Override
        public void start(Stage primaryStage) {
            StackPane root = new StackPane();
            ComboBox<String> cb = new ComboBox<String>();
            cb.setPrefSize(150, 20);
            root.getChildren().add(cb);
            Scene scene = new Scene(root, 300, 250);
            primaryStage.setScene(scene);
            primaryStage.show();
        ObservableList<String> data = FXCollections.observableArrayList(
                "chocolate", "salmon", "gold", "coral", "darkorchid",
                "darkgoldenrod", "lightsalmon", "black", "rosybrown", "blue",
                "blueviolet", "brown");
          cb.setItems(data);
          Callback<ListView<String>, ListCell<String>> factory = new Callback<ListView<String>, ListCell<String>>(){
              @Override
              public ListCell<String> call(ListView<String> list){
                  return new ColorRectCell();
          cb.setCellFactory(factory);
          cb.setButtonCell(factory.call(null));
          static class ColorRectCell extends ListCell<String>{
              @Override
              public void updateItem(String item, boolean empty){
                  super.updateItem(item, empty);
                  Rectangle rect = new Rectangle(120,13);
                  rect.setStroke(Color.BLACK);
                  if(item != null){
                      rect.setFill(Color.web(item));
                      setGraphic(rect);
        public static void main(String[] args) {
            launch(args);
    Thanks.

    Just add
    setTooltip(new Tooltip(item));
    in your updateItem(...) method.

  • JavaFX as renderer for JSF view components

    I don;t know if I am asking the right question.
    Since javaFX has GUI components, Does sun provide JavaFX as a default renderer for JSF applications. Wouldn't that be cool say I define my view in some standard format and just configure a renderer in some xml and then with a magic, the UI is all based on JavaFX

    ejp wrote:
    So my question is primarily 'does this make sense?' Yes. I don't see why this wouldn't make sense.
    If so, secondly, does this imply I should/shouldn't use Facelets?For now on, it's recommend to start with it. It will be the default supported view technology as per JSF 2.0 and it offers much more advantages than the legacy JSP. Here's a nice document to start with: [https://facelets.dev.java.net/nonav/docs/dev/docbook.html].
    Thirdly, what else might I need in the stack?Maybe a 3rd party component library to take out the boring UI and ajaxical work from your hands. For example RichFaces.

  • Problem with JavaFX 8 Self-contained Application !

    Hello everybody,
    I generate a JavaFX 8 Self-Contained Application for Windows (.msi).
    Eclipse 4.3.1 (Kepler)
    JDK 8 B116 (EA - i don't use the lasts beta versions (B117 and B118) because there is a bug during installation for Windows XP)
    Scene builder 2.0 (EA)
    When i install this application (exec .msi) on my PC (Windows XP SP3 - JDK 7 and 8 installed), no problem.
    So i install this application on 2 others PC (PC without JDK 8 installed).
    The first PC on Windows XP SP3 (JDK 5 and 6 installed) : display problem - the font is very big as if I had made a zoom on the contents of the window !
    The second PC on Windows 7 PRO (JDK 7 installed) - when in launch the application by the system menu, i have two strange problems
    1/ when i move my mouse on the content of the window, this content becomes black !
    2/ it's necessary to resize the window (full screen) and to come back to the original size to obtain a correct display !
    I don't know where is the problem(s) ?
    is it linked to JDK 8 (BETA version) embedded ?
    If you have a idea do not hesitate !
    Thanks you in advance
    IBACK

    I only use external FW HDDs for my video work; my Capture Scratch files are on external drives and I export finished movies to external drives. My project files are on my system drive, this is the best way to work, I have never had any problems I could associate with this configuration
    I am assuming you've gone thru your project, your timeline and everything is kosher. Is everything fully rendered? Have you mixed down your audio? Have you tried exporting just the last 30 seconds of one of the projects to see if you can replicate the problem?

Maybe you are looking for

  • Subreports showing blank prompt after SP3 upgrade

    We recently applied SP3 to our Business Object software and now any BW based subreports are displaying blank Prompt screen when we try to run the Queries individually. The report works fine if we use the "Refresh All" option instead of the Single rep

  • To copy a site from the net to edit.

    i have been asked to edit someones website, and i am having trouble gaining the information i need to download the site into dreamweaver to work on. what info do i need specifically for the ftp server, etc? sorry for being so daft in this. even if so

  • Submit a pdf instead of a picture How?

    When browsing with safari on a websight I'ts only possible to submit a picture instead of a pdf with My CV. WHY?.

  • Isight build-in-camera

    to all expert, in your openion please let me know the possible problem of my mac os v10.4 build-in-camera. because the light indicator is glowing but the screen is blank. no picture appear.

  • I am  unable to load GRAPHIC files using the transaction SFP.

    I am  unable to load GRAPHIC files using the transaction SFP. The error message says that there is no connection to the below given url.    http://<hostname:8000>/sap/bc/fp/ is it something like i have to activate this service in transaction sicf ?