Search in sources :

Example 46 with BorderPane

use of javafx.scene.layout.BorderPane in project mastering-java by Kingminghuang.

the class MultipleBounceBall method start.

@Override
public void start(Stage primaryStage) throws Exception {
    MultipleBallPane ballPane = new MultipleBallPane();
    ballPane.setStyle("-fx-border-color: red");
    Button addBtn = new Button("+");
    Button subtractBtn = new Button("-");
    HBox hBox = new HBox(10);
    hBox.getChildren().addAll(addBtn, subtractBtn);
    hBox.setAlignment(Pos.CENTER);
    addBtn.setOnAction(event -> ballPane.add());
    subtractBtn.setOnAction(event -> ballPane.subtract());
    ballPane.setOnMousePressed(event -> ballPane.pause());
    ballPane.setOnMouseReleased(event -> ballPane.play());
    ScrollBar speedCtrl = new ScrollBar();
    speedCtrl.setMax(50);
    speedCtrl.setValue(25);
    ballPane.rateProperty().bind(speedCtrl.valueProperty());
    BorderPane borderPane = new BorderPane();
    borderPane.setCenter(ballPane);
    borderPane.setTop(speedCtrl);
    borderPane.setBottom(hBox);
    Scene scene = new Scene(borderPane, DEFAULT_WIDTH, DEFAULT_HEIGHT);
    primaryStage.setTitle("Multiple Bounce Ball");
    primaryStage.setScene(scene);
    primaryStage.show();
}
Also used : HBox(javafx.scene.layout.HBox) BorderPane(javafx.scene.layout.BorderPane) Button(javafx.scene.control.Button) Scene(javafx.scene.Scene) ScrollBar(javafx.scene.control.ScrollBar)

Example 47 with BorderPane

use of javafx.scene.layout.BorderPane in project intellij-community by JetBrains.

the class IpnbJfxUtils method createHtmlPanel.

public static JComponent createHtmlPanel(@NotNull final String source, int width) {
    final JFXPanel javafxPanel = new JFXPanel() {

        @Override
        protected void processMouseWheelEvent(MouseWheelEvent e) {
            final Container parent = getParent();
            final MouseEvent parentEvent = SwingUtilities.convertMouseEvent(this, e, parent);
            parent.dispatchEvent(parentEvent);
        }
    };
    javafxPanel.setBackground(IpnbEditorUtil.getBackground());
    Platform.runLater(() -> {
        final WebView webView = new WebView();
        webView.setContextMenuEnabled(false);
        webView.setOnDragDetected(event -> {
        });
        final WebEngine engine = webView.getEngine();
        initHyperlinkListener(engine);
        final boolean hasMath = source.contains("$");
        if (hasMath) {
            engine.setOnStatusChanged(event -> adjustHeight(webView, javafxPanel, source));
        } else {
            engine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
                if (newValue == Worker.State.SUCCEEDED) {
                    adjustHeight(webView, javafxPanel, source);
                }
            });
        }
        final BorderPane pane = new BorderPane(webView);
        final String prefix;
        if (hasMath) {
            prefix = String.format(ourMathJaxPrefix, width - 500, EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize());
        } else {
            prefix = String.format(ourPrefix, width - 500);
        }
        final String content = prefix + convertToHtml(source) + ourPostfix;
        engine.loadContent(content);
        final Scene scene = new Scene(pane, 0, 0);
        javafxPanel.setScene(scene);
        updateLaf(LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo, engine, javafxPanel);
    });
    return javafxPanel;
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) BorderPane(javafx.scene.layout.BorderPane) MouseEvent(java.awt.event.MouseEvent) MouseWheelEvent(java.awt.event.MouseWheelEvent) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) WebEngine(javafx.scene.web.WebEngine)

Example 48 with BorderPane

use of javafx.scene.layout.BorderPane in project Media-Library by The-Rain-Goddess.

the class ApplicationWindow method start.

@Override
public void start(Stage rootStage) throws Exception {
    AnchorPane componentWindow = new AnchorPane();
    VBox componentLayout = new VBox();
    BorderPane tableDisplay = new BorderPane();
    search = new TextField();
    //set main window size
    componentWindow.setMinHeight(WINDOW_MIN_HEIGHT);
    componentWindow.setMinWidth(WINDOW_MIN_WIDTH);
    //align dataTable
    tableDisplay.setRight(setupMediaDataTable());
    tableDisplay.setLeft(setupMediaFileBrowser());
    tableDisplay.setTop(setupMediaPlayer());
    ;
    VBox.setMargin(tableDisplay, new Insets(10, 10, 10, 10));
    componentLayout.getChildren().addAll(setupMenuBar(), tableDisplay);
    //add componentLayout to Window
    componentWindow.getChildren().addAll(componentLayout);
    //Create the scene and add the parent container to it
    Scene scene = new Scene(componentWindow, WINDOW_MIN_WIDTH, WINDOW_MIN_HEIGHT);
    //Add the Scene to the Stage
    rootStage.setScene(scene);
    rootStage.getIcons().add(new Image(this.getClass().getResourceAsStream("media_library.png")));
    rootStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) Insets(javafx.geometry.Insets) TextField(javafx.scene.control.TextField) Scene(javafx.scene.Scene) Image(javafx.scene.image.Image) AnchorPane(javafx.scene.layout.AnchorPane) VBox(javafx.scene.layout.VBox)

Example 49 with BorderPane

use of javafx.scene.layout.BorderPane in project aima-java by aimacode.

the class VacuumEnvironmentViewCtrl method initialize.

@Override
public void initialize(Environment env) {
    if (env instanceof VacuumEnvironment) {
        this.locations = ((VacuumEnvironment) env).getLocations();
        envStateView.getChildren().clear();
        envStateView.getColumnConstraints().clear();
        ColumnConstraints colCons = new ColumnConstraints();
        colCons.setPercentWidth(100.0 / locations.size());
        int i = 0;
        for (String loc : locations) {
            BorderPane pane = new BorderPane();
            pane.setTop(new Label(loc));
            pane.setStyle("-fx-background-color: white");
            envStateView.add(pane, i++, 0);
            envStateView.getColumnConstraints().add(colCons);
        }
    }
    super.initialize(env);
}
Also used : BorderPane(javafx.scene.layout.BorderPane) VacuumEnvironment(aima.core.environment.vacuum.VacuumEnvironment) ColumnConstraints(javafx.scene.layout.ColumnConstraints) Label(javafx.scene.control.Label)

Example 50 with BorderPane

use of javafx.scene.layout.BorderPane in project aima-java by aimacode.

the class NQueensSearchApp method createRootPane.

/**
	 * Defines state view, parameters, and call-back functions and calls the
	 * simulation pane builder to create layout and controller objects.
	 */
@Override
public Pane createRootPane() {
    BorderPane root = new BorderPane();
    StackPane stateView = new StackPane();
    stateViewCtrl = new NQueensViewCtrl(stateView);
    List<Parameter> params = createParameters();
    SimulationPaneBuilder builder = new SimulationPaneBuilder();
    builder.defineParameters(params);
    builder.defineStateView(stateView);
    builder.defineInitMethod(this::initialize);
    builder.defineSimMethod(this::simulate);
    simPaneCtrl = builder.getResultFor(root);
    simPaneCtrl.setParam(SimulationPaneCtrl.PARAM_SIM_SPEED, 1);
    return root;
}
Also used : BorderPane(javafx.scene.layout.BorderPane) SimulationPaneBuilder(aima.gui.fx.framework.SimulationPaneBuilder) NQueensViewCtrl(aima.gui.fx.views.NQueensViewCtrl) Parameter(aima.gui.fx.framework.Parameter) StackPane(javafx.scene.layout.StackPane)

Aggregations

BorderPane (javafx.scene.layout.BorderPane)93 Scene (javafx.scene.Scene)56 Button (javafx.scene.control.Button)19 Label (javafx.scene.control.Label)16 FXMLLoader (javafx.fxml.FXMLLoader)14 Stage (javafx.stage.Stage)13 StackPane (javafx.scene.layout.StackPane)12 IOException (java.io.IOException)11 Parameter (aima.gui.fx.framework.Parameter)10 SimulationPaneBuilder (aima.gui.fx.framework.SimulationPaneBuilder)10 File (java.io.File)10 HashMap (java.util.HashMap)8 TableView (javafx.scene.control.TableView)8 HBox (javafx.scene.layout.HBox)8 Insets (javafx.geometry.Insets)7 TextField (javafx.scene.control.TextField)7 Map (java.util.Map)6 MenuItem (javafx.scene.control.MenuItem)6 TableColumn (javafx.scene.control.TableColumn)6 FXML (javafx.fxml.FXML)5