Example usage for javafx.scene.layout BorderPane BorderPane

List of usage examples for javafx.scene.layout BorderPane BorderPane

Introduction

In this page you can find the example usage for javafx.scene.layout BorderPane BorderPane.

Prototype

public BorderPane() 

Source Link

Document

Creates a BorderPane layout.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {

    // Use a border pane as the root for scene
    BorderPane border = new BorderPane();

    HBox hbox = addHBox();//from w w w .j ava 2s  . c  o m
    border.setTop(hbox);
    border.setLeft(addVBox());

    // Add a stack to the HBox in the top region
    addStackPane(hbox);

    // To see only the grid in the center, uncomment the following statement
    // comment out the setCenter() call farther down        
    //        border.setCenter(addGridPane());

    // Choose either a TilePane or FlowPane for right region and comment out the
    // one you aren't using        
    border.setRight(addFlowPane());
    //        border.setRight(addTilePane());

    // To see only the grid in the center, comment out the following statement
    // If both setCenter() calls are executed, the anchor pane from the second
    // call replaces the grid from the first call        
    border.setCenter(addAnchorPane(addGridPane()));

    Scene scene = new Scene(border, 585, 415);
    stage.setScene(scene);
    stage.setTitle("Layout Sample");
    stage.show();
}

From source file:be.makercafe.apps.makerbench.editors.XMLEditor.java

public XMLEditor(String tabText, Path path) {
    super(tabText);

    this.caCodeArea = new CodeArea("");
    this.caCodeArea.setEditable(true);
    this.caCodeArea.setParagraphGraphicFactory(LineNumberFactory.get(caCodeArea));
    this.caCodeArea.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE);
    this.caCodeArea.getStylesheets().add(this.getClass().getResource("xml-highlighting.css").toExternalForm());
    this.caCodeArea.textProperty().addListener((obs, oldText, newText) -> {
        this.caCodeArea.setStyleSpans(0, computeHighlighting(newText));
    });//  ww  w  .j  a  v a2  s .co  m
    addContextMenu(this.caCodeArea);

    try {
        this.caCodeArea.replaceText(FileUtils.readFileToString(path.toFile()));
    } catch (IOException ex) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Error reading file.", ex);
    }

    BorderPane rootPane = new BorderPane();

    toolBar = createToolBar();
    rootPane.setTop(toolBar);
    rootPane.setCenter(caCodeArea);
    this.getTab().setContent(rootPane);

}

From source file:de.scoopgmbh.copper.monitoring.client.context.ApplicationContext.java

public ApplicationContext() {
    mainStackPane = new StackPane();
    mainPane = new BorderPane();
    mainPane.setId("background");//important for css
    mainStackPane.getChildren().add(mainPane);
    messageProvider = new MessageProvider(ResourceBundle.getBundle("de.scoopgmbh.copper.gui.message"));

    final Preferences prefs = Preferences.userRoot().node("de.scoopgmbh.coppermonitor");

    SettingsModel defaultSettings = new SettingsModel();
    AuditralColorMapping newItem = new AuditralColorMapping();
    newItem.color.setValue(Color.rgb(255, 128, 128));
    newItem.loglevelRegEx.setValue("1");
    defaultSettings.auditralColorMappings.add(newItem);
    byte[] defaultModelbytes;
    ByteArrayOutputStream os = null;
    try {/*from  www  . ja v  a  2 s.com*/
        os = new ByteArrayOutputStream();
        ObjectOutputStream o = new ObjectOutputStream(os);
        o.writeObject(defaultSettings);
        defaultModelbytes = os.toByteArray();
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }

    settingsModelSingleton = defaultSettings;
    ByteArrayInputStream is = null;
    try {
        is = new ByteArrayInputStream(prefs.getByteArray(SETTINGS_KEY, defaultModelbytes));
        ObjectInputStream o = new ObjectInputStream(is);
        Object object = o.readObject();
        if (object instanceof SettingsModel) {
            settingsModelSingleton = (SettingsModel) object;
        }
    } catch (Exception e) {
        logger.error("", e);
        getIssueReporterSingleton()
                .reportWarning("Can't load settings from (Preferences: " + prefs + ") use defaults instead", e);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            ByteArrayOutputStream os = null;
            try {
                os = new ByteArrayOutputStream();
                ObjectOutputStream o = new ObjectOutputStream(os);
                o.writeObject(settingsModelSingleton);
                prefs.putByteArray(SETTINGS_KEY, os.toByteArray());
            } catch (IOException e) {
                throw new RuntimeException(e);
            } finally {
                if (os != null) {
                    try {
                        os.close();
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
    }));
}

From source file:Main.java

@Override
public void start(final Stage stage) {
    final Node loginPanel = makeDraggable(createLoginPanel());
    final Node confirmationPanel = makeDraggable(createConfirmationPanel());
    final Node progressPanel = makeDraggable(createProgressPanel());

    loginPanel.relocate(0, 0);//from  w  w  w . j  a  v  a  2  s  . c  om
    confirmationPanel.relocate(0, 67);
    progressPanel.relocate(0, 106);

    final Pane panelsPane = new Pane();
    panelsPane.getChildren().addAll(loginPanel, confirmationPanel, progressPanel);

    final BorderPane sceneRoot = new BorderPane();

    BorderPane.setAlignment(panelsPane, Pos.TOP_LEFT);
    sceneRoot.setCenter(panelsPane);

    final CheckBox dragModeCheckbox = new CheckBox("Drag mode");
    BorderPane.setMargin(dragModeCheckbox, new Insets(6));
    sceneRoot.setBottom(dragModeCheckbox);

    dragModeActiveProperty.bind(dragModeCheckbox.selectedProperty());

    final Scene scene = new Scene(sceneRoot, 400, 300);
    stage.setScene(scene);
    stage.setTitle("Draggable Panels Example");
    stage.show();
}

From source file:investor.views.CompaniesView.java

public void InitView() {
    selectedRange = DataRange.THREEMONTH;
    selectedChart = "line";
    pane = new VBox();
    lineChart = LinearChartManager.linear();
    lineChart.setTitle("");

    table = new TableView();

    try {/*  ww  w .jav a  2  s  .  com*/
        table.getItems().addAll(NetworkManager.show(DataType.SPOL));
    } catch (Exception e) {
        System.out.println("Something went wrong when populating market indicisies view");
    }

    table.getColumns().addAll(initColumns());

    table.setRowFactory(tv -> {
        TableRow<Index> row = new TableRow<Index>();
        row.setOnMouseClicked(event -> {
            if (event.getClickCount() == 2 && (!row.isEmpty())) {
                Index rowData = row.getItem();
                selectedIndex = rowData;
                //System.out.println(rowData);
                try {
                    lastData = NetworkManager.showMore(rowData.getSymbol(), selectedRange);
                    System.out.println(lastData.length);

                    if (selectedChart.equals("line")) {
                        lineChart.getData().clear();
                        lineChart.setTitle(rowData.getName());
                        LinearChartManager.addSeries(lineChart, lastData, selectedRange);
                        if (pointerType != null && pointerType != "hide") {
                            OnPointerChange();
                        }
                    } else {
                        CandleChart.generateData(lastData);
                        candleChart = new CandleChart();
                        CandleChart.CandleStickChart chart = candleChart.createChart();
                        chart.setTitle(rowData.getName());
                        pane.getStylesheets().add("resources/css/CandleStickChart.css");
                        borderPane.setCenter(chart);
                    }
                } catch (Exception ex) {
                    System.out.println("Error while downloading indicise " + ex.toString());
                }
            }
        });
        return row;
    });

    //table.setItems(initRows());
    table.setEditable(false);

    VBox vBox = (VBox) pane;

    borderPane = new BorderPane();
    borderPane.setCenter(lineChart);
    borderPane.setRight(addMenuButtons());

    vBox.getChildren().add(table);
    vBox.getChildren().add(borderPane);
}

From source file:com.cdd.bao.editor.endpoint.BrowseEndpoint.java

public BrowseEndpoint(Stage stage) {
    this.stage = stage;

    stage.setTitle("BioAssay Schema Browser");

    treeRoot = new TreeItem<>(new Branch(this));
    treeView = new TreeView<>(treeRoot);
    treeView.setEditable(true);/*from w  w  w .ja  va2s .  c om*/
    treeView.setCellFactory(p -> new BrowseTreeCell());
    treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldval, newval) -> {
        changeValue(newval.getValue());
    });

    display = new DisplaySchema();

    StackPane sp1 = new StackPane(), sp2 = new StackPane();
    sp1.getChildren().add(treeView);
    sp2.getChildren().add(display);

    splitter = new SplitPane();
    splitter.setOrientation(Orientation.HORIZONTAL);
    splitter.getItems().addAll(sp1, sp2);
    splitter.setDividerPositions(0.4, 1.0);

    root = new BorderPane();
    root.setTop(menuBar);
    root.setCenter(splitter);

    Scene scene = new Scene(root, 700, 600, Color.WHITE);

    stage.setScene(scene);

    treeView.setShowRoot(false);

    rebuildTree();

    Platform.runLater(() -> treeView.getFocusModel().focus(treeView.getSelectionModel().getSelectedIndex())); // for some reason it defaults to not the first item

    new Thread(() -> backgroundLoadTemplates()).start();
}

From source file:poe.trade.assist.Main.java

@Override
public void start(Stage stage) {
    //      try {
    //         fh = new FileHandler("D:\\MxDownload\\POE\\poe.trade.assist\\assist.log");
    //      } catch (IOException e) {
    //         e.printStackTrace();
    //      }/*from w  ww.  ja  va2  s .  c o m*/
    //      logger.addHandler(fh);
    //      SimpleFormatter formatter = new SimpleFormatter();
    //      fh.setFormatter(formatter);
    //      logger.info("Init application.");

    BorderPane root = new BorderPane();

    config = Config.load();
    config.get(Config.SEARCH_FILE).ifPresent(searchFileTextField::setText);

    searchFileTextField.setPromptText("Search CSV File URL or blank");
    searchFileTextField.setTooltip(new Tooltip(
            "Any url to a valid poe.trade.assist CSV search file. Can be googlespreadsheet URL. If left blank, will load search.csv file instead"));
    searchFileTextField.setMinWidth(330);
    HBox.setHgrow(searchFileTextField, Priority.ALWAYS);

    List<Search> searchList = loadSearchListFromFile();

    AutoSearchService autoSearchService = new AutoSearchService(
            Boolean.parseBoolean(config.get(Config.AUTO_ENABLE).get()),
            Float.parseFloat(config.get(Config.SEARCH_MINUTES).get()));
    searchPane = new SearchPane(searchList);
    resultPane = new ResultPane(searchFileTextField, this);

    autoSearchService.searchesProperty().bind(searchPane.dataProperty());

    EventHandler<ActionEvent> reloadAction = e -> {
        System.out.println("Loading search file: " + searchFileTextField.getText());
        List<Search> newList = loadSearchListFromFile();
        searchPane.dataProperty().clear();
        searchPane.dataProperty().addAll(newList);
        autoSearchService.restart();
        if (searchPane.dataProperty().size() > 0)
            searchPane.searchTable.getSelectionModel().select(0);
    };

    searchFileTextField.setOnAction(reloadAction);
    resultPane.loadButton.setOnAction(reloadAction);
    resultPane.defaultButton.setOnAction(e -> {
        searchFileTextField.setText(DEFAULT_SEARCH_CSV_FILE);
        resultPane.loadButton.fire();
    });

    resultPane.runNowButton.setOnAction(e -> autoSearchService.restart());
    //        autoSearchService.minsToSleepProperty().bind(resultPane.noOfMinsTextField.textProperty());
    setupResultPaneBinding(searchPane, resultPane, autoSearchService);
    if (searchList.size() > 0)
        searchPane.searchTable.getSelectionModel().select(0);

    stage.setOnCloseRequest(we -> {
        saveSearchList(searchPane);
        config.setProperty(Config.SEARCH_FILE, searchFileTextField.getText());
        config.setProperty(Config.SOUND_FILE, resultPane.soundButton.getUserData().toString());
        config.save();
    });

    config.get(Config.SOUND_FILE).ifPresent(resultPane.soundButton::setUserData);

    autoSearchService.restart();

    //        HBox container = new HBox(5, searchPane, resultPane);
    SplitPane container = new SplitPane(searchPane, resultPane);
    container.setDividerPositions(0.1);
    HBox.setHgrow(searchPane, Priority.ALWAYS);
    HBox.setHgrow(resultPane, Priority.ALWAYS);
    container.setMaxWidth(Double.MAX_VALUE);
    //        root.getChildren().addAll(container);
    root.setCenter(container);
    Scene scene = new Scene(root);
    stage.getIcons().add(new Image("/48px-Durian.png"));
    stage.titleProperty().bind(new SimpleStringProperty("poe.trade.assist v5 (Durian) - ")
            .concat(autoSearchService.messageProperty()));
    //        stage.setWidth(1200);
    //        stage.setHeight(550);
    stage.setMaximized(true);
    stage.setScene(scene);
    stage.show();
    searchPane.searchTable.requestFocus();
}

From source file:be.makercafe.apps.makerbench.Main.java

@Override
public void start(Stage primaryStage) {
    setupWorkspace();/* ww  w .j a  va 2s  .  c om*/
    rootContextMenu = createViewerContextMenu();
    viewer = createViewer();

    this.stage = primaryStage;
    BorderPane p = new BorderPane();

    p.setTop(createMenuBar());

    // p.setLeft(viewer);
    tabFolder = new TabPane();
    BorderPane bodyPane = new BorderPane();
    TextArea taConsole = new TextArea();
    taConsole.setPrefSize(Double.MAX_VALUE, 200.0);
    taConsole.setEditable(false);

    Console console = new Console(taConsole);
    PrintStream ps = new PrintStream(console, true);
    System.setOut(ps);
    System.setErr(ps);

    bodyPane.setBottom(taConsole);
    bodyPane.setCenter(tabFolder);
    SplitPane splitpane = new SplitPane();
    splitpane.getItems().addAll(viewer, bodyPane);
    splitpane.setDividerPositions(0.0f, 1.0f);
    p.setCenter(splitpane);

    Scene scene = new Scene(p, 1024, 800);
    //scene.getStylesheets().add(this.getClass().getResource("/styles/java-keywords.css").toExternalForm());

    primaryStage.setResizable(true);
    primaryStage.setTitle("Makerbench");
    primaryStage.setScene(scene);
    //primaryStage.getIcons().add(new Image("/path/to/stackoverflow.jpg"));
    primaryStage.show();
}

From source file:org.copperengine.monitoring.client.context.ApplicationContext.java

public ApplicationContext(String contextId) {
    this.contextId = contextId;
    mainStackPane = new StackPane();
    mainPane = new BorderPane();
    mainStackPane.getChildren().add(mainPane);
    messageProvider = new MessageProvider(ResourceBundle.getBundle("org.copperengine.gui.message"));

    final Preferences prefs = Preferences.userRoot().node("org.copperengine.coppermonitor");

    SettingsModel defaultSettings = new SettingsModel();
    AuditralColorMapping newItem = new AuditralColorMapping();
    newItem.color.setValue(Color.rgb(255, 128, 128));
    newItem.loglevelRegEx.setValue("1");
    defaultSettings.auditralColorMappings.add(newItem);

    byte[] defaultModelbytes;
    ByteArrayOutputStream os = null;
    try {//from  w  w  w  .  j  av a 2  s .com
        os = new ByteArrayOutputStream();
        ObjectOutputStream o = new ObjectOutputStream(os);
        o.writeObject(defaultSettings);
        defaultModelbytes = os.toByteArray();
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }

    try {
        settingsModelSingleton = SettingsModel.from(prefs, defaultModelbytes, contextId);
    } catch (Exception e) {
        logger.error("", e);
        getIssueReporterSingleton()
                .reportWarning("Can't load settings from (Preferences: " + prefs + ") use defaults instead", e);
        settingsModelSingleton = defaultSettings;
    }

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            settingsModelSingleton.saveSettings(prefs, ApplicationContext.this.contextId);
        }
    }));
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 500, 250, Color.WHITE);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(10);/*from ww  w .ja  v a 2  s  .  co m*/
    gridpane.setVgap(10);
    root.setCenter(gridpane);

    ObservableList<Person> leaders = getPeople();
    final ObservableList<Person> teamMembers = FXCollections.observableArrayList();

    ListView<Person> leaderListView = createLeaderListView(leaders);
    TableView<Person> employeeTableView = createEmployeeTableView(teamMembers);

    Label bossesLbl = new Label("Boss");
    GridPane.setHalignment(bossesLbl, HPos.CENTER);
    gridpane.add(bossesLbl, 0, 0);
    gridpane.add(leaderListView, 0, 1);

    Label emplLbl = new Label("Employees");
    GridPane.setHalignment(emplLbl, HPos.CENTER);
    gridpane.add(emplLbl, 2, 0);
    gridpane.add(employeeTableView, 2, 1);

    leaderListView.getSelectionModel().selectedItemProperty()
            .addListener((ObservableValue<? extends Person> observable, Person oldValue, Person newValue) -> {
                if (observable != null && observable.getValue() != null) {
                    teamMembers.clear();
                    teamMembers.addAll(observable.getValue().employeesProperty());
                }
            });
    primaryStage.setScene(scene);
    primaryStage.show();
}