Example usage for javafx.scene Scene getStylesheets

List of usage examples for javafx.scene Scene getStylesheets

Introduction

In this page you can find the example usage for javafx.scene Scene getStylesheets.

Prototype

public final ObservableList<String> getStylesheets() 

Source Link

Document

Gets an observable list of string URLs linking to the stylesheets to use with this scene's contents.

Usage

From source file:com.bekwam.mavenpomupdater.Main.java

@Override
public void start(Stage primaryStage) throws Exception {

    ///*from ww w .  ja  v a  2s .c o m*/
    // handle command line options
    //
    Application.Parameters params = getParameters();

    List<String> unnamedList = params.getUnnamed();

    Options options = new Options();
    options.addOption("help", false, "Print this message");
    options.addOption("hidpi", false, "Use high-DPI scaling");

    CommandLineParser p = new BasicParser();
    CommandLine cmd = p.parse(options, unnamedList.toArray(new String[0]));

    HelpFormatter formatter = new HelpFormatter();

    if (cmd.hasOption("help")) {
        if (log.isDebugEnabled()) {
            log.debug("[START] running as help command");
        }
        formatter.printHelp("Main", options);
        return;
    }

    AbstractModule module = null;
    if (runningAsJNLP()) {

        if (log.isInfoEnabled()) {
            log.info("using jnlp module and jnlp favorites store");
        }
        module = new MPUJNLPModule();
    } else {

        if (log.isInfoEnabled()) {
            log.info("using standalone module and in-memory favorites store");
        }
        module = new MPUStandaloneModule();
    }

    //
    // setup google guice
    //
    final Injector injector = Guice.createInjector(module);

    BuilderFactory builderFactory = new JavaFXBuilderFactory();

    Callback<Class<?>, Object> guiceControllerFactory = clazz -> injector.getInstance(clazz);

    //
    // setup icons
    //
    primaryStage.getIcons().add(new Image("images/mpu_icon_64.png"));

    //
    // load fxml and wire controllers
    //
    FXMLLoader mainViewLoader = new FXMLLoader(getClass().getResource("mavenpomupdater.fxml"), null,
            builderFactory, guiceControllerFactory);
    Parent mainView = mainViewLoader.load();
    MainViewController mainViewController = mainViewLoader.getController();

    FXMLLoader alertViewLoader = new FXMLLoader(getClass().getResource("alert.fxml"), null, builderFactory,
            guiceControllerFactory);
    Parent alertView = alertViewLoader.load();

    //
    // i'm continuing this manual wiring to 1) accommodate a potential
    // bi-directional reference problem and 2) to make sure that guice
    // doesn't return different object for the main -> alert and alert ->
    // main dependency injections
    //

    final AlertController alertController = alertViewLoader.getController();
    mainViewController.alertController = alertController;
    alertController.mainViewControllerRef = new WeakReference<MainViewController>(mainViewController);

    //
    // add FlowPane, StackPane objects (defined in program and outside of 
    // FXML)
    //
    final FlowPane fp = new FlowPane();
    fp.setAlignment(Pos.CENTER);
    fp.getChildren().add(alertView);
    fp.getStyleClass().add("alert-background-pane");

    final StackPane sp = new StackPane();
    sp.getChildren().add(fp); // initially hide the alert
    sp.getChildren().add(mainView);

    //
    // setup scene
    //
    Scene scene = new Scene(sp);
    scene.getStylesheets().add("com/bekwam/mavenpomupdater/mpu.css");

    scene.setOnKeyPressed(keyEvent -> {
        KeyCode key = keyEvent.getCode();
        if (key == KeyCode.ESCAPE && (sp.getChildren().get(1) == fp)) {
            if (log.isDebugEnabled()) {
                log.debug("[ESCAPE]");
            }
            alertController.action();
        }
    });

    //
    // setup stage
    //
    primaryStage.setTitle("Maven POM Version Updater");
    primaryStage.setScene(scene);

    if (cmd.hasOption("hidpi")) {

        if (log.isInfoEnabled()) {
            log.info("running in Hi-DPI display mode");
        }
        primaryStage.setWidth(2560.0);
        primaryStage.setHeight(1440.0);
        primaryStage.setMinWidth(1920.0);
        primaryStage.setMinHeight(1080.0);

        mainViewController.adjustForHiDPI();

    } else {
        if (log.isInfoEnabled()) {
            log.info("running in normal display mode");
        }

        primaryStage.setWidth(1280.0);
        primaryStage.setHeight(800.0);
        primaryStage.setMinWidth(1024.0);
        primaryStage.setMinHeight(768.0);

    }

    primaryStage.show();
}

From source file:ijfx.ui.test.DummyCategories.java

@Override
public void run() {

    ExplorableList output = new ExplorableList();
    ExplorableList output2 = new ExplorableList();
    ExplorableList output3 = new ExplorableList();

    for (int i = 0; i != 10; i++) {

        MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false));
        MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false));
        MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false));
        MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble());
        MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble());

        Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4);
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        output.add(explorable);//from w  w  w  .j  ava  2  s .com

    }

    for (int i = 0; i != 5; i++) {

        MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false));
        MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false));
        MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false));
        MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble());
        MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble());

        Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4);
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        output2.add(explorable);

    }

    for (int i = 0; i != 3; i++) {

        MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false));
        MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false));
        MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false));
        MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble());
        MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble());

        Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4);
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false)));
        output3.add(explorable);

    }

    Pane pane = ctrl.addCategory("Cat 1").setElements("Cat 1", output) //set the element that the first line will contain
            .addCategory("Cat 2").setElements("Cat 2", output2).setMaxItemPerCategory(8).generate(); // returns the Pane that contains the view

    ctrl.setElements("Cat 2", output3);
    ctrl.update(); // updates the pane returned previously

    Platform.runLater(() -> {

        Stage stage = new Stage();
        stage.initModality(Modality.APPLICATION_MODAL);
        Scene scene = new Scene(pane, 550, 600);

        ////////CSS part///////

        URL cssURL = getClass().getResource("/ijfx/ui/flatterfx.css");
        if (cssURL != null) {
            scene.getStylesheets().add(cssURL.toExternalForm());
        }

        stage.setScene(scene);
        stage.show();

    });

}

From source file:de.micromata.mgc.javafx.ControllerService.java

public <M, W extends Parent, C extends ModelController<M>> Pair<W, C> loadControlWithModelNewScene(
        Class<C> controlToLoad, Class<W> widget, M model, Controller parentController) {
    Pair<W, C> ret = loadControlWithModel(controlToLoad, widget, model, parentController);
    C controller = ret.getSecond();/*from  w w  w .  ja v  a2 s  .  c o m*/
    W wig = ret.getFirst();
    Stage stage = new Stage();
    //    controller.setOwningStage(stage);
    Scene s = new Scene(wig, AbstractConfigDialog.PREF_WIDTH, AbstractConfigDialog.PREF_HEIGHT);
    controller.setScene(s);
    controller.setStage(stage);
    stage.setScene(s);
    s.getStylesheets().add(FXCssUtil.CSS);
    return ret;
}

From source file:com.properned.application.SystemController.java

@FXML
public void openHelpDialog() {
    logger.info("Open the help dialog");
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(getClass().getResource("/com/properned/gui/helpFrame.fxml"));
    loader.setResources(MessageReader.getInstance().getBundle());

    try {//from   ww  w .java 2  s  .  c  o  m
        loader.load();
        Parent root = loader.getRoot();
        Stage modalDialog = new Stage();
        modalDialog.setTitle(MessageReader.getInstance().getMessage("menu.help.help"));
        modalDialog.setResizable(true);
        modalDialog.getIcons().add(new Image("/com/properned/style/icon/icon_16.png"));

        Scene scene = new Scene(root);
        scene.getStylesheets().add("/com/properned/style/application.css");
        modalDialog.setScene(scene);
        modalDialog.show();
    } catch (IOException e) {
        Properned.getInstance().showError(MessageReader.getInstance().getMessage("error.openFrame"), e);
    }
}

From source file:com.properned.application.SystemController.java

@FXML
public void openAboutDialog() {
    logger.info("Open the about dialog");
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(getClass().getResource("/com/properned/gui/aboutFrame.fxml"));
    loader.setResources(MessageReader.getInstance().getBundle());

    try {//from w  w w  .  j a v  a 2  s . co  m
        loader.load();

        Parent root = loader.getRoot();

        Stage modalDialog = new Stage(StageStyle.UTILITY);
        modalDialog.initOwner(Properned.getInstance().getPrimaryStage());
        modalDialog.setTitle(MessageReader.getInstance().getMessage("menu.help.about"));
        modalDialog.setResizable(false);

        Scene scene = new Scene(root);
        scene.getStylesheets().add("/com/properned/style/application.css");

        modalDialog.setScene(scene);

        modalDialog.showAndWait();
    } catch (IOException e) {
        Properned.getInstance().showError(MessageReader.getInstance().getMessage("error.openFrame"), e);
    }
}

From source file:com.properned.application.SystemController.java

@FXML
public void openLocaleDialog() {
    logger.info("Open the locale dialog");

    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(getClass().getResource("/com/properned/gui/localeFrame.fxml"));
    loader.setResources(MessageReader.getInstance().getBundle());

    try {/*from  ww  w  .j  ava  2s .c o m*/
        loader.load();

        Parent root = loader.getRoot();

        Stage modalDialog = new Stage(StageStyle.UNIFIED);
        modalDialog.initModality(Modality.APPLICATION_MODAL);
        modalDialog.initOwner(Properned.getInstance().getPrimaryStage());
        modalDialog.setTitle(MessageReader.getInstance().getMessage("manageLocale.title"));
        modalDialog.setResizable(true);
        modalDialog.getIcons().add(new Image("/com/properned/style/icon/icon_16.png"));

        Scene scene = new Scene(root);
        scene.getStylesheets().add("/com/properned/style/application.css");

        modalDialog.setScene(scene);

        modalDialog.showAndWait();
    } catch (IOException e) {
        Properned.getInstance().showError(MessageReader.getInstance().getMessage("error.openFrame"), e);
    }
}

From source file:ca.wumbo.doommanager.client.controller.FileEditorController.java

/**
 * Starts the GUI for connecting to a server for a shared project.
 *//*from   w w w .  j a  va  2s .  c  om*/
public void openConnectGUI() {
    log.debug("Loading a new connect wizard.");
    ConnectWizardController connectWizard = SpringContainer.getContext().getBean(ConnectWizardController.class);

    log.trace("Creating the scene.");
    Scene scene = new Scene(connectWizard.getRootPane());
    scene.getStylesheets().add(cssPath);

    log.trace("Creating stage to display window with the scene.");
    Stage stage = new Stage();
    stage.setTitle("Remote Project Connection");
    stage.setResizable(false);
    stage.initModality(Modality.NONE);
    stage.initOwner(coreController.getStage());
    stage.setResizable(false);
    stage.setScene(scene);
    stage.show();
    log.trace("Connect wizard displayed.");
}

From source file:eu.over9000.skadi.ui.MainWindow.java

@Override
public void start(final Stage stage) throws Exception {
    this.stage = stage;

    this.detailPane = new ChannelDetailPane(this);

    this.bp = new BorderPane();
    this.sp = new SplitPane();
    this.sb = new StatusBar();

    this.setupTable();
    this.setupToolbar(stage);

    this.sp.getItems().add(this.table);

    this.bp.setTop(this.tb);
    this.bp.setCenter(this.sp);
    this.bp.setBottom(this.sb);

    final Scene scene = new Scene(this.bp, 1280, 720);
    scene.getStylesheets().add(this.getClass().getResource("/styles/copyable-label.css").toExternalForm());
    scene.setOnDragOver(event -> {//from w w w  .  ja v  a  2 s .  co  m
        final Dragboard d = event.getDragboard();
        if (d.hasUrl() || d.hasString()) {
            event.acceptTransferModes(TransferMode.COPY);
        } else {
            event.consume();
        }
    });
    scene.setOnDragDropped(event -> {
        final Dragboard d = event.getDragboard();
        boolean success = false;
        if (d.hasUrl()) {
            final String user = StringUtil.extractUsernameFromURL(d.getUrl());
            if (user != null) {
                success = this.channelHandler.addChannel(user, this.sb);
            } else {
                this.sb.setText("dragged url is no twitch stream");
            }
        } else if (d.hasString()) {
            success = this.channelHandler.addChannel(d.getString(), this.sb);
        }
        event.setDropCompleted(success);
        event.consume();

    });

    stage.setTitle("Skadi");
    stage.getIcons().add(new Image(this.getClass().getResourceAsStream("/icons/skadi.png")));
    stage.setScene(scene);
    stage.show();

    stage.iconifiedProperty().addListener((obs, oldV, newV) -> {
        if (this.currentState.isMinimizeToTray()) {
            if (newV) {
                stage.hide();
            }
        }
    });
    stage.setOnCloseRequest(event -> Platform.exit());

    this.bindColumnWidths();

}

From source file:ca.wumbo.doommanager.client.controller.FileEditorController.java

/**
 * Creates a new DXML project and has the user set it up, then places it in
 * the tab./*from w w  w  .j a  va2  s  . c o m*/
 */
public void newDXMLProject() {
    // Create the wizard and wait for the result.
    DXMLProjectCreatorController controller = SpringContainer.getContext()
            .getBean(DXMLProjectCreatorController.class);

    Scene scene = new Scene(controller.getRootPane());
    scene.getStylesheets().add(cssPath);

    Stage stage = new Stage();
    stage.setTitle("DXML Project Setup Wizard");
    stage.setResizable(false);
    stage.initModality(Modality.WINDOW_MODAL);
    stage.initOwner(coreController.getStage());
    stage.setScene(scene);
    controller.setStage(stage); // Required for it to be able to close properly.
    controller.setParentStage(coreController.getStage()); // Required as well to block input if browsing for files.
    stage.showAndWait();

    // If the user finished the work, get the DXML file.
    if (!controller.wasClosedByUser()) {
        DXML dxmlData = controller.getDxmlData();
        // The file must also be valid. This should not ever be false unless there is a coding error.
        if (dxmlData.isValidDXMLFile()) {
            // Create it on the disk.
            DXMLCreationStatus status = dxmlData.createOnDisk();

            // If the status shows success, add it to the view.
            switch (status) {
            case SUCCESS:
                // Since it succeeded, open up the project now.
                String path = dxmlData.getProjectInfo().getProjectLocationPath() + File.separator;
                path += dxmlData.getCompilation().getFilename() + File.separator;
                path += dxmlData.getCompilation().getFilename() + ".dxml"; // TODO - support any case extension.
                openDXMLProject(Paths.get(path));
                break;
            case ALREADY_EXISTS:
                log.warn("DXML project already exists at the specified location. Aborting.");
                break;
            case FOLDER_CREATION_FAILURE:
                log.warn("Unable to create directory for the project. Are your permissions correct? Aborting.");
                break;
            case DXML_FILE_EXISTS:
                log.warn("DXML file already exists at location, aborting to prevent potential overwrite.");
                break;
            case DXML_FILE_CREATION_FAILURE:
                log.warn("Unable to create DXML file at location, are your permissions correct? Aborting.");
                break;
            case XML_MARSHALL_ERROR:
                log.warn("Unable to create the .dxml file. Are your file permissions correct? Aborting.");
                break;
            case FAILED:
                log.warn("Unable to create the necessary DXML file/folder resources at the provided location.");
                break;
            case INVALID_DXML_DATA:
            case BAD_PROJECT_PATH:
                log.warn("DXML project has corrupt data. Contact a developer, Aborting [Reason: {}].",
                        status.name());
                break;
            default:
                throw new DXMLException(
                        "DXML status for disk creation returned an unexpected enumeration. Contact a developer.");
            }
        } else {
            throw new DXMLException(
                    "DXML Wizard has not properly generated a proper file. Please contact a developer.");
        }
    } else {
        log.info("DXML project cancelled by user.");
    }
}

From source file:statos2_0.StatOS2_0.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");

    GridPane root = new GridPane();
    Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
    root.setAlignment(Pos.CENTER);/* ww w .  j  a  va  2s .  c  o m*/
    root.setHgap(10);
    root.setVgap(10);
    root.setPadding(new Insets(25, 25, 25, 25));

    Text scenetitle = new Text("");

    root.add(scenetitle, 0, 0, 2, 1);
    scenetitle.setId("welcome-text");
    Label userName = new Label(":");
    //userName.setId("label");
    root.add(userName, 0, 1);

    TextField userTextField = new TextField();
    root.add(userTextField, 1, 1);

    Label pw = new Label(":");
    root.add(pw, 0, 2);

    PasswordField pwBox = new PasswordField();
    root.add(pwBox, 1, 2);
    ComboBox store = new ComboBox();
    store.setItems(GetByTag());
    root.add(store, 1, 3);

    Button btn = new Button("");
    //btn.setPrefSize(100, 20);
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);

    root.add(hbBtn, 1, 4);

    Button btn2 = new Button("");
    //btn2.setPrefSize(100, 20);
    HBox hbBtn2 = new HBox(10);
    hbBtn2.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn2.getChildren().add(btn2);
    root.add(hbBtn2, 1, 5);

    final Text actiontarget = new Text();
    root.add(actiontarget, 1, 6);

    btn2.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            System.exit(0);
        }
    });

    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            if (userTextField.getText().equals("")) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else if (pwBox.getText().equals("")) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else if (store.getSelectionModel().getSelectedIndex() < 0) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else {
                try {
                    String[] resu = checkpas(userTextField.getText(), pwBox.getText());
                    if (resu[0].equals("-1")) {
                        Alert alert = new Alert(Alert.AlertType.ERROR);
                        alert.setTitle("!");
                        alert.setHeaderText("!");
                        alert.setContentText("   !");
                        alert.showAndWait();
                    } else if (storecheck((store.getSelectionModel().getSelectedIndex() + 1)) == false) {
                        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
                        alert.setTitle("!");
                        alert.setHeaderText("!");
                        alert.setContentText("     !"
                                + "\n       -  ");
                        Optional<ButtonType> result = alert.showAndWait();
                        if (result.get() == ButtonType.OK) {
                            // ... user chose OK
                            idstore = store.getSelectionModel().getSelectedIndex() + 1;
                            updsel(idstore, Integer.parseInt(resu[0]));
                            MainA ma = new MainA();
                            ma.m = (idstore);
                            ma.MT = "m" + idstore;
                            ma.selid = Integer.parseInt(resu[0]);
                            ma.nameseller = resu[1];
                            ma.storename = store.getSelectionModel().getSelectedItem().toString();
                            ma.start(primaryStage);
                        } else {
                            // ... user chose CANCEL or closed the dialog
                        }

                    } else {
                        // 

                        idstore = store.getSelectionModel().getSelectedIndex() + 1;
                        updsel(idstore, Integer.parseInt(resu[0]));
                        MainA ma = new MainA();
                        ma.m = (idstore);
                        ma.MT = "m" + idstore;
                        ma.selid = Integer.parseInt(resu[0]);
                        ma.nameseller = resu[1];
                        ma.storename = store.getSelectionModel().getSelectedItem().toString();

                        ma.start(primaryStage);

                    }

                } catch (NoSuchAlgorithmException ex) {
                    Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
                } catch (Exception ex) {
                    Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            /**
             * if((userTextField.getText().equals("admin"))&(pwBox.getText().equals("admin"))){
             * actiontarget.setId("acttrue");
             * actiontarget.setText(" !");
             * MainA ma = new MainA();
             * ma.m=1;
             * try {
             * ma.m=1;
             * ma.MT="m1";
             * ma.start(primaryStage);
             * } catch (Exception ex) {
             * Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
             * }
             * }else{
             * actiontarget.setId("actfalse");
             * actiontarget.setText(" !");
             * } **/

        }
    });
    //Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
    //sSize.getHeight();
    Scene scene = new Scene(root, sSize.getWidth(), sSize.getHeight());

    primaryStage.setScene(scene);
    scene.getStylesheets().add(StatOS2_0.class.getResource("adminStatOS.css").toExternalForm());
    primaryStage.show();
}