Example usage for javafx.application Application setUserAgentStylesheet

List of usage examples for javafx.application Application setUserAgentStylesheet

Introduction

In this page you can find the example usage for javafx.application Application setUserAgentStylesheet.

Prototype

public static void setUserAgentStylesheet(String url) 

Source Link

Document

Set the user agent stylesheet used by the whole application.

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Application.setUserAgentStylesheet(getClass().getResource("sample.css").toExternalForm());

    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);

    primaryStage.setScene(scene);//from w  ww . j  a  v a2s.  co m
    primaryStage.show();
}

From source file:wpdisplaytest.WPDisplayTest.java

@Override
public void start(Stage primaryStage)
        throws InterruptedException, JSONException, FileNotFoundException, IOException {
    final Parameters params = getParameters();
    final List<String> parameters = params.getRaw();
    SettingsHandler settings = ServiceHandler.getInstance().getSettings();
    try {//from w  ww.ja va  2s. c  om
        settings.loadProps(parameters.get(0));
    } catch (Exception ex) {
        settings.loadProps("display.cfg");
    }

    //        File f = new File("wpstyle.css");
    //        System.out.println(f.getCanonicalPath()+":"+f.canRead()+":"+f.exists());
    Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
    StyleManager.getInstance().addUserAgentStylesheet(
            Paths.get(settings.getProperty("css_path"), "wpstyle.css").toUri().toURL().toExternalForm());
    //System.out.printf(this.getClass().getClassLoader().getResource("").getPath()+":"+java.nio.file.Paths.get("display.cfg"));
    //System.out.println(new File(".").getAbsoluteFile());

    // Set root logger level to DEBUG and its only appender to A1.
    //String jsonstr = "{\"numlegs\":2,\"legduration\":40000,\"numovertimes\":0,\"overtimeduration\":20000}";
    BasicConfigurator.configure();
    Postgres db = new Postgres();
    db.connect(
            "jdbc:postgresql://" + settings.getProperty("database_url") + "/"
                    + settings.getProperty("database_db") + "?tcpKeepAlive=true",
            settings.getProperty("database_user"), settings.getProperty("database_pass"));
    ServiceHandler.getInstance().setDb(db);

    FileService fs = FileService.getInst();
    fs.setDb(db);

    ThriftConnector<WPDisplayServer, WPTalkBackClient> tc = new ThriftConnector<WPDisplayServer, WPTalkBackClient>();
    ServiceHandler.getInstance().setThriftconnector(tc);
    try {
        ServiceHandler.getInstance().setSenderthread(
                new SenderThread(settings.getProperty("pyramid_ip"), settings.getIntProperty("pyramid_port")));
    } catch (UnknownHostException ex) {
        Logger.getLogger(WPDisplayTest.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SocketException ex) {
        Logger.getLogger(WPDisplayTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    ServiceHandler.getInstance().setHorn(new Horn(ServiceHandler.getInstance().getSenderthread(),
            settings.getIntProperty("shorthorntime"), settings.getIntProperty("longhorntime")));

    ControllerScreen root = new ControllerScreen(db, primaryStage);
    ScoreBoardScreen sbc = new ScoreBoardScreen(db);
    root.addScreen(sbc, "scoreboard");
    root.addScreen(new SplashScreen(db), "splash");
    //ServiceHandler.getInstance().setOrganizer(OrganizerBuilder.build(jsonstr, sbc));
    root.switchScreen("splash");

    ServiceHandler.getInstance().registerCleanup(primaryStage);
    //ResultWrapper rw = root.sendCommand(new LoadTeams(1,2));
    //if (rw.isError()){
    //    System.out.println(rw.get("error"));
    //}
    Scene scene = new Scene(root, 1024, 768);
    //Scene scene = new Scene(root);        
    primaryStage.setScene(scene);

    this.moveToSecondaryIfExists(primaryStage);
    //primaryStage.setFullScreen(true);        
    primaryStage.show();

}