3 Replies Latest reply: Sep 2, 2011 2:14 AM by 884213 RSS

    Netbeans Platform Application and JavaFX CSS API

    884213
      I'm using JavaFX in my Netbeans Platform Application. I load JavaFX scene with next code:
      SwingUtilities.invokeLater(new Runnable() 
                  {
                      @Override
                      public void run() 
                      {
                          javaFxPanel.setSize(getSize());
                          add(javaFxPanel, BorderLayout.CENTER);
                          Platform.runLater(new Runnable() {
      
                              @Override
                              public void run() {
                                      Group branchNode = new Group();
                                      
                                      Scene scene = new Scene(branchNode);
                                      try{
                                          scene.getStylesheets().add("C:\\Xlab\\pandora\\branches\\simon-welcome-screen\\TraineeGuiApp\\modules\\ui\\welcomescreen\\main.css");
                                      }
                                      catch(Exception e)
                                      {
                                         Exceptions.printStackTrace(e);
                                      }
                                      Rectangle rect = new Rectangle(100,100); 
                                      rect.setLayoutX(50); 
                                      rect.setLayoutY(50); 
                                      rect.getStyleClass().add("my-rect"); 
                                      ((Group)scene.getRoot()).getChildren().add(rect);
                                      // Add scene to panel
                                      javaFxPanel.setScene(scene);
                                      javaFxPanel.setVisible(true);
                              }
      
                          });
                          //Application.launch(FXApplication.class, null);
      
                      }
                  });
      As you can see i provide absolute path to my css file. CSS file and class that i want to use it from are in same package. I also tried providing just a "main.css" string to scene.getStylesheets().add("main.css"); method.

      I have no idea why this is not working. Any suggestions?

      Edited by: user8867321 on 1.9.2011 9:56