Search in sources :

Example 6 with GridPane

use of javafx.scene.layout.GridPane in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerToolsTab method populate.

private void populate() {
    final VBox toolsPane = new VBox();
    final Text title = new TextWithStyle(tr("Tools"), TITLE_CSS_CLASS);
    toolsPane.getStyleClass().add(CONFIGURATION_PANE_CSS_CLASS);
    toolsPane.getChildren().add(title);
    final GridPane toolsContentPane = new GridPane();
    toolsContentPane.getStyleClass().add("grid");
    Button openTerminal = new Button(tr("Open a terminal"));
    openTerminal.getStyleClass().addAll("wineToolButton", "openTerminal");
    openTerminal.setOnMouseClicked(e -> {
        this.lockAll();
        winePrefixContainerController.openTerminalInPrefix(container);
        this.unlockAll();
    });
    GridPane.setHalignment(openTerminal, HPos.CENTER);
    this.lockableElements.add(openTerminal);
    toolsContentPane.add(openTerminal, 0, 0);
    toolsContentPane.add(wineToolCaption(tr("Open a terminal")), 0, 1);
    Button createShortcut = new Button();
    createShortcut.getStyleClass().addAll("wineToolButton", "openTerminal");
    createShortcut.setOnMouseClicked(event -> {
        this.lockAll();
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle(tr("Choose executable"));
        File file = fileChooser.showOpenDialog(this.getContent().getScene().getWindow());
        if (file != null) {
            winePrefixContainerController.createShortcut(container, file.getName(), file.getName(), this::unlockAll, e -> Platform.runLater(() -> new ErrorMessage("Error", e).show()));
        }
        this.unlockAll();
    });
    GridPane.setHalignment(createShortcut, HPos.CENTER);
    this.lockableElements.add(createShortcut);
    toolsContentPane.add(createShortcut, 1, 0);
    toolsContentPane.add(wineToolCaption(tr("Create shortcut")), 1, 1);
    Button runExecutable = new Button();
    runExecutable.getStyleClass().addAll("wineToolButton", "runExecutable");
    runExecutable.setOnMouseClicked(event -> {
        this.lockAll();
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle(tr("Choose executable"));
        File file = fileChooser.showOpenDialog(this.getContent().getScene().getWindow());
        if (file != null) {
            winePrefixContainerController.runInPrefix(container, file.getAbsolutePath(), this::unlockAll, e -> Platform.runLater(() -> new ErrorMessage("Error", e).show()));
        }
    });
    GridPane.setHalignment(runExecutable, HPos.CENTER);
    this.lockableElements.add(runExecutable);
    toolsContentPane.add(runExecutable, 2, 0);
    toolsContentPane.add(wineToolCaption(tr("Run executable")), 2, 1);
    toolsPane.getChildren().addAll(toolsContentPane);
    toolsContentPane.getColumnConstraints().addAll(new ColumnConstraintsWithPercentage(25), new ColumnConstraintsWithPercentage(25), new ColumnConstraintsWithPercentage(25), new ColumnConstraintsWithPercentage(25));
    this.setContent(toolsPane);
}
Also used : TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) GridPane(javafx.scene.layout.GridPane) Button(javafx.scene.control.Button) FileChooser(javafx.stage.FileChooser) Text(javafx.scene.text.Text) ErrorMessage(org.phoenicis.javafx.views.common.ErrorMessage) VBox(javafx.scene.layout.VBox) File(java.io.File)

Example 7 with GridPane

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

the class ApplicationWindow method showAddWindow.

//private add window mutators
private void showAddWindow() {
    //create new Stage
    Stage addWindow = new Stage();
    addWindow.setTitle("ADD Media");
    GridPane componentLayout = getAddWindowLayout();
    //add all window components to componentLayout
    componentLayout.getChildren().addAll(getWindowComponents(addWindow));
    //create Scene
    Scene scene = new Scene(componentLayout, 550, 300);
    //set Screen to show Scene
    addWindow.setScene(scene);
    addWindow.show();
}
Also used : GridPane(javafx.scene.layout.GridPane) Stage(javafx.stage.Stage) Scene(javafx.scene.Scene)

Example 8 with GridPane

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

the class ConnectFourApp method createRootPane.

@Override
public Pane createRootPane() {
    model = new ConnectFourModel();
    BorderPane root = new BorderPane();
    ToolBar toolBar = new ToolBar();
    toolBar.setStyle("-fx-background-color: rgb(0, 0, 200)");
    clearBtn = new Button("Clear");
    clearBtn.setOnAction(ev -> model.initGame());
    strategyCombo = new ComboBox<>();
    strategyCombo.getItems().addAll("Iterative Deepening Alpha-Beta", "Advanced Alpha-Beta");
    strategyCombo.getSelectionModel().select(0);
    timeCombo = new ComboBox<>();
    timeCombo.getItems().addAll("2sec", "4sec", "6sec", "8sec");
    timeCombo.getSelectionModel().select(1);
    proposeBtn = new Button("Propose Move");
    proposeBtn.setOnAction(ev -> model.proposeMove((timeCombo.getSelectionModel().getSelectedIndex() + 1) * 2, strategyCombo.getSelectionModel().getSelectedIndex()));
    toolBar.getItems().addAll(clearBtn, new Separator(), strategyCombo, timeCombo, proposeBtn);
    root.setTop(toolBar);
    final int rows = model.getRows();
    final int cols = model.getCols();
    BorderPane boardPane = new BorderPane();
    ColumnConstraints colCons = new ColumnConstraints();
    colCons.setPercentWidth(100.0 / cols);
    GridPane btnPane = new GridPane();
    GridPane diskPane = new GridPane();
    btnPane.setHgap(10);
    btnPane.setPadding(new Insets(10, 10, 0, 10));
    btnPane.setStyle("-fx-background-color: rgb(0, 50, 255)");
    diskPane.setPadding(new Insets(10, 10, 10, 10));
    diskPane.setStyle("-fx-background-color: rgb(0, 50, 255)");
    colBtns = new Button[cols];
    for (int i = 0; i < cols; i++) {
        Button colBtn = new Button("" + (i + 1));
        colBtn.setId("" + (i + 1));
        colBtn.setMaxWidth(Double.MAX_VALUE);
        colBtn.setOnAction(ev -> {
            String id = ((Button) ev.getSource()).getId();
            int col = Integer.parseInt(id);
            model.makeMove(col - 1);
        });
        colBtns[i] = colBtn;
        btnPane.add(colBtn, i, 0);
        GridPane.setHalignment(colBtn, HPos.CENTER);
        btnPane.getColumnConstraints().add(colCons);
        diskPane.getColumnConstraints().add(colCons);
    }
    boardPane.setTop(btnPane);
    diskPane.setMinSize(0, 0);
    diskPane.setPrefSize(cols * 100, rows * 100);
    RowConstraints rowCons = new RowConstraints();
    rowCons.setPercentHeight(100.0 / rows);
    for (int i = 0; i < rows; i++) diskPane.getRowConstraints().add(rowCons);
    disks = new Circle[rows * cols];
    for (int i = 0; i < rows * cols; i++) {
        Circle disk = new Circle(30);
        disk.radiusProperty().bind(Bindings.min(Bindings.divide(diskPane.widthProperty(), cols * 3), Bindings.divide(diskPane.heightProperty(), rows * 3)));
        disks[i] = disk;
        diskPane.add(disk, i % cols, i / cols);
        GridPane.setHalignment(disk, HPos.CENTER);
    }
    boardPane.setCenter(diskPane);
    root.setCenter(boardPane);
    statusBar = new Label();
    statusBar.setMaxWidth(Double.MAX_VALUE);
    statusBar.setStyle("-fx-background-color: rgb(0, 0, 200); -fx-font-size: 20");
    root.setBottom(statusBar);
    model.addObserver(this::update);
    return root;
}
Also used : Circle(javafx.scene.shape.Circle) BorderPane(javafx.scene.layout.BorderPane) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) ColumnConstraints(javafx.scene.layout.ColumnConstraints) Label(javafx.scene.control.Label) RowConstraints(javafx.scene.layout.RowConstraints) Button(javafx.scene.control.Button) ToolBar(javafx.scene.control.ToolBar) Separator(javafx.scene.control.Separator)

Example 9 with GridPane

use of javafx.scene.layout.GridPane in project jgnash by ccavanaugh.

the class BudgetTableController method initialize.

@FXML
private void initialize() {
    final Preferences preferences = Preferences.userNodeForPackage(BudgetTableController.class);
    runningTotalsButton.selectedProperty().setValue(preferences.getBoolean(RUNNING_TOTALS, false));
    rateLimitExecutor = new ScheduledThreadPoolExecutor(1, new DefaultDaemonThreadFactory(), new ThreadPoolExecutor.DiscardPolicy());
    tableWidthChangeListener = (observable, oldValue, newValue) -> {
        if (newValue != null && !oldValue.equals(newValue)) {
            optimizeColumnWidths();
        }
    };
    updateHeights();
    yearSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(LocalDate.now().getYear() - YEAR_MARGIN, LocalDate.now().getYear() + YEAR_MARGIN, LocalDate.now().getYear(), 1));
    accountTreeView.getStylesheets().addAll(StyleClass.HIDE_VERTICAL_CSS);
    accountTreeView.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
    accountTreeView.setShowRoot(false);
    accountTreeView.setEditable(true);
    accountTreeView.fixedCellSizeProperty().bind(rowHeight);
    accountSummaryTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    accountSummaryTable.getStylesheets().addAll(StyleClass.HIDE_VERTICAL_CSS, StyleClass.HIDE_HORIZONTAL_CSS);
    accountSummaryTable.setItems(expandedAccountList);
    accountSummaryTable.fixedCellSizeProperty().bind(rowHeight);
    accountSummaryTable.setSelectionModel(new NullTableViewSelectionModel<>(accountSummaryTable));
    accountTypeTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    accountTypeTable.getStylesheets().add(StyleClass.HIDE_HEADER_CSS);
    accountTypeTable.setItems(accountGroupList);
    accountTypeTable.fixedCellSizeProperty().bind(rowHeight);
    accountTypeTable.prefHeightProperty().bind(rowHeight.multiply(Bindings.size(accountGroupList)).add(BORDER_MARGIN));
    accountTypeTable.setSelectionModel(new NullTableViewSelectionModel<>(accountTypeTable));
    accountGroupPeriodSummaryTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    accountGroupPeriodSummaryTable.getStylesheets().addAll(StyleClass.HIDE_HEADER_CSS, StyleClass.HIDE_HORIZONTAL_CSS, StyleClass.HIDE_VERTICAL_CSS);
    accountGroupPeriodSummaryTable.setItems(accountGroupList);
    accountGroupPeriodSummaryTable.fixedCellSizeProperty().bind(rowHeight);
    accountGroupPeriodSummaryTable.prefHeightProperty().bind(rowHeight.multiply(Bindings.size(accountGroupList)).add(BORDER_MARGIN));
    accountGroupPeriodSummaryTable.setSelectionModel(new NullTableViewSelectionModel<>(accountGroupPeriodSummaryTable));
    buildAccountTreeTable();
    buildAccountTypeTable();
    buildAccountSummaryTable();
    buildAccountGroupSummaryTable();
    accountSummaryTable.maxWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
    accountGroupPeriodSummaryTable.maxWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
    accountSummaryTable.minWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
    accountGroupPeriodSummaryTable.minWidthProperty().bind(minSummaryColumnWidth.multiply(3.0).add(BORDER_MARGIN));
    accountTreeView.expandedItemCountProperty().addListener((observable, oldValue, newValue) -> JavaFXUtils.runLater(this::updateExpandedAccountList));
    final ChangeListener<Object> budgetChangeListener = (observable, oldValue, newValue) -> handleBudgetChange();
    budget.addListener(budgetChangeListener);
    yearSpinner.valueProperty().addListener(budgetChangeListener);
    runningTotalsButton.selectedProperty().addListener(budgetChangeListener);
    visibleColumnCount.addListener(budgetChangeListener);
    runningTotalsButton.selectedProperty().addListener((observable, oldValue, newValue) -> preferences.putBoolean(RUNNING_TOTALS, newValue));
    /* Setting the tables as un-managed effectively removes these tables from the GridPane.  The tables are
           redundant if showing the amounts as running balances. */
    accountSummaryTable.managedProperty().bind(runningTotalsButton.selectedProperty().not());
    accountGroupPeriodSummaryTable.managedProperty().bind(runningTotalsButton.selectedProperty().not());
    horizontalScrollBar.setMin(0);
    horizontalScrollBar.maxProperty().bind(periodCount.subtract(visibleColumnCount));
    horizontalScrollBar.setUnitIncrement(1);
    horizontalScrollBar.disableProperty().bind(periodCount.lessThanOrEqualTo(1));
    // shift the table right and left with the ScrollBar value
    horizontalScrollBar.valueProperty().addListener((observable, oldValue, newValue) -> {
        /* must be synchronized to prevent a race condition from multiple events and an out of
                     * bounds exception */
        synchronized (this) {
            /* don't try unless columns exist.  This can occur if the UI is not large enough to display
                         * a minimum of one period of information.
                         */
            if (periodTable.getColumns().size() > 0) {
                final int newIndex = (int) Math.round(newValue.doubleValue());
                if (newIndex > index) {
                    while (newIndex > index) {
                        handleShiftRight();
                    }
                } else if (newIndex < index) {
                    while (newIndex < index) {
                        handleShiftLeft();
                    }
                }
            }
        }
    });
    ThemeManager.fontScaleProperty().addListener((observable, oldValue, newValue) -> updateHeights());
}
Also used : Pos(javafx.geometry.Pos) Engine(jgnash.engine.Engine) BigDecimal(java.math.BigDecimal) Budget(jgnash.engine.budget.Budget) MessageProperty(jgnash.engine.message.MessageProperty) DefaultDaemonThreadFactory(jgnash.util.DefaultDaemonThreadFactory) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) TreeTableCell(javafx.scene.control.TreeTableCell) BudgetPeriodDescriptor(jgnash.engine.budget.BudgetPeriodDescriptor) TableView(javafx.scene.control.TableView) NullTableViewSelectionModel(jgnash.uifx.control.NullTableViewSelectionModel) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) MessageListener(jgnash.engine.message.MessageListener) HBox(javafx.scene.layout.HBox) NotNull(jgnash.util.NotNull) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) Spinner(javafx.scene.control.Spinner) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) JavaFXUtils(jgnash.uifx.util.JavaFXUtils) AccountGroup(jgnash.engine.AccountGroup) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) BudgetGoal(jgnash.engine.budget.BudgetGoal) List(java.util.List) LocalDate(java.time.LocalDate) Optional(java.util.Optional) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableList(javafx.collections.ObservableList) Message(jgnash.engine.message.Message) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) BudgetPeriodResults(jgnash.engine.budget.BudgetPeriodResults) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TreeItem(javafx.scene.control.TreeItem) EngineFactory(jgnash.engine.EngineFactory) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) Bindings(javafx.beans.binding.Bindings) IntegerProperty(javafx.beans.property.IntegerProperty) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) TreeTableView(javafx.scene.control.TreeTableView) ResourceBundle(java.util.ResourceBundle) ThemeManager(jgnash.uifx.skin.ThemeManager) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) Comparators(jgnash.engine.Comparators) FXMLUtils(jgnash.uifx.util.FXMLUtils) BudgetResultsModel(jgnash.engine.budget.BudgetResultsModel) CheckBox(javafx.scene.control.CheckBox) MainView(jgnash.uifx.views.main.MainView) Preferences(java.util.prefs.Preferences) TimeUnit(java.util.concurrent.TimeUnit) TreeTableColumn(javafx.scene.control.TreeTableColumn) CommodityFormat(jgnash.text.CommodityFormat) StageUtils(jgnash.uifx.util.StageUtils) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) StyleClass(jgnash.uifx.skin.StyleClass) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) Account(jgnash.engine.Account) ChangeListener(javafx.beans.value.ChangeListener) ScrollBar(javafx.scene.control.ScrollBar) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) Preferences(java.util.prefs.Preferences) DefaultDaemonThreadFactory(jgnash.util.DefaultDaemonThreadFactory) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) FXML(javafx.fxml.FXML)

Example 10 with GridPane

use of javafx.scene.layout.GridPane in project jgnash by ccavanaugh.

the class SelectAccountSecuritiesDialog method showAndWait.

public boolean showAndWait() {
    // Create the base dialog
    final Stage dialog = new Stage(StageStyle.DECORATED);
    dialog.initModality(Modality.APPLICATION_MODAL);
    dialog.initOwner(MainView.getPrimaryStage());
    dialog.setTitle(resources.getString("Title.AccountSecurities"));
    final Label availableLabel = new Label(resources.getString("Title.Available"));
    availableLabel.getStyleClass().add(StyleClass.LIST_TITLE_STYLE);
    final Label currentLabel = new Label(resources.getString("Title.Current"));
    currentLabel.getStyleClass().add(StyleClass.LIST_TITLE_STYLE);
    final GridPane gridPane = createGridPane();
    gridPane.add(availableLabel, 0, 0);
    gridPane.add(sourceListView, 0, 1);
    gridPane.add(createButtonBox(), 1, 1);
    gridPane.add(currentLabel, 2, 0);
    gridPane.add(targetListView, 2, 1);
    gridPane.add(createButtonBar(), 0, 2, 3, 1);
    dialog.setScene(new Scene(gridPane));
    dialog.getScene().getStylesheets().add(MainView.DEFAULT_CSS);
    dialog.getScene().getRoot().styleProperty().bind(ThemeManager.styleProperty());
    dialog.getScene().getRoot().getStyleClass().addAll("form", "dialog");
    StageUtils.addBoundsListener(dialog, this.getClass(), MainView.getPrimaryStage());
    dialog.showAndWait();
    return result;
}
Also used : GridPane(javafx.scene.layout.GridPane) FontAwesomeLabel(jgnash.resource.font.FontAwesomeLabel) Label(javafx.scene.control.Label) Stage(javafx.stage.Stage) Scene(javafx.scene.Scene)

Aggregations

GridPane (javafx.scene.layout.GridPane)28 Label (javafx.scene.control.Label)19 Insets (javafx.geometry.Insets)8 Button (javafx.scene.control.Button)7 TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)7 Dialog (javafx.scene.control.Dialog)6 TextField (javafx.scene.control.TextField)6 VBox (javafx.scene.layout.VBox)6 Scene (javafx.scene.Scene)5 Text (javafx.scene.text.Text)5 Stage (javafx.stage.Stage)5 Pair (javafx.util.Pair)5 ButtonType (javafx.scene.control.ButtonType)4 Region (javafx.scene.layout.Region)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Node (javafx.scene.Node)3 ColumnConstraintsWithPercentage (org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage)3 File (java.io.File)2 ResourceBundle (java.util.ResourceBundle)2