Java Code Examples for javafx.scene.control.Button#setPadding()

The following examples show how to use javafx.scene.control.Button#setPadding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartPerformanceBenchmark.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private Button switchToTestCase(final String label, final ChartTestCase testCase, final Node chart) {
    final Button button = new Button(label);
    button.setPadding(new Insets(5, 5, 5, 5));
    button.setMaxHeight(Double.MAX_VALUE);
    VBox.setVgrow(button, Priority.ALWAYS);
    button.setOnAction(evt -> {
        if (timer != null) {
            timer.interrupt();
            timer = null;
        }
        test = testCase;
        root.setCenter(chart);
        test.updateDataSet();
        LOGGER.atInfo().log("reset FPS averages");
        meter.resetAverages();
    });
    return button;
}
 
Example 2
Source File: Zoomer.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
public HBox getZoomInteractorBar() {
    final Separator separator = new Separator();
    separator.setOrientation(Orientation.VERTICAL);
    final HBox buttonBar = new HBox();
    buttonBar.setPadding(new Insets(1, 1, 1, 1));
    final Button zoomOut = new Button(null, new Glyph(FONT_AWESOME, "\uf0b2").size(FONT_SIZE));
    zoomOut.setPadding(new Insets(3, 3, 3, 3));
    zoomOut.setTooltip(new Tooltip("zooms to origin and enables auto-ranging"));
    final Button zoomModeXY = new Button(null, new Glyph(FONT_AWESOME, "\uf047").size(FONT_SIZE));
    zoomModeXY.setPadding(new Insets(3, 3, 3, 3));
    zoomModeXY.setTooltip(new Tooltip("set zoom-mode to X & Y range (N.B. disables auto-ranging)"));
    final Button zoomModeX = new Button(null, new Glyph(FONT_AWESOME, "\uf07e").size(FONT_SIZE));
    zoomModeX.setPadding(new Insets(3, 3, 3, 3));
    zoomModeX.setTooltip(new Tooltip("set zoom-mode to X range (N.B. disables auto-ranging)"));
    final Button zoomModeY = new Button(null, new Glyph(FONT_AWESOME, "\uf07d").size(FONT_SIZE));
    zoomModeY.setPadding(new Insets(3, 3, 3, 3));
    zoomModeY.setTooltip(new Tooltip("set zoom-mode to Y range (N.B. disables auto-ranging)"));

    zoomOut.setOnAction(evt -> {
        zoomOrigin();
        for (final Axis axis : getChart().getAxes()) {
            axis.setAutoRanging(true);
        }
    });
    zoomModeXY.setOnAction(evt -> setAxisMode(AxisMode.XY));
    zoomModeX.setOnAction(evt -> setAxisMode(AxisMode.X));
    zoomModeY.setOnAction(evt -> setAxisMode(AxisMode.Y));
    buttonBar.getChildren().addAll(separator, zoomOut, zoomModeXY, zoomModeX, zoomModeY);
    return buttonBar;
}
 
Example 3
Source File: TableViewer.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
/**
 * Helper function to initialize the UI elements for the Interactor toolbar.
 * 
 * @return HBox node with the toolbar elements
 */
protected HBox getInteractorBar() {
    final Separator separator = new Separator();
    separator.setOrientation(Orientation.VERTICAL);
    final HBox buttonBar = new HBox();
    buttonBar.setPadding(new Insets(1, 1, 1, 1));
    final Button switchTableView = new Button(null, tableView);
    switchTableView.setPadding(new Insets(3, 3, 3, 3));
    switchTableView.setTooltip(new Tooltip("switches between graph and table view"));

    final Button copyToClipBoard = new Button(null, clipBoardIcon);
    copyToClipBoard.setPadding(new Insets(3, 3, 3, 3));
    copyToClipBoard.setTooltip(new Tooltip("copy selected content top system clipboard"));
    copyToClipBoard.setOnAction(e -> this.copySelectedToClipboard());

    final Button saveTableView = new Button(null, saveIcon);
    saveTableView.setPadding(new Insets(3, 3, 3, 3));
    saveTableView.setTooltip(new Tooltip("store actively shown content as .csv file"));
    saveTableView.setOnAction(e -> this.exportGridToCSV());

    switchTableView.setOnAction(evt -> {
        switchTableView.setGraphic(table.isVisible() ? tableView : graphView);
        table.setVisible(!table.isVisible());
        getChart().getPlotForeground().setMouseTransparent(!table.isVisible());
        table.setMouseTransparent(!table.isVisible());
        dsModel.datasetsChanged(null);
    });

    buttonBar.getChildren().addAll(separator, switchTableView, copyToClipBoard, saveTableView);
    return buttonBar;
}
 
Example 4
Source File: MarsNode.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public Button createGreenhouseDialog(Farming farm) {
	String name = farm.getBuilding().getNickName();
	Button b = new Button(name);
	b.setMaxWidth(Double.MAX_VALUE);

     List<String> choices = new ArrayList<>();
     choices.add("Lettuce");
     choices.add("Green Peas");
     choices.add("Carrot");

     ChoiceDialog<String> dialog = new ChoiceDialog<>("List of Crops", choices);
     dialog.setTitle(name);
     dialog.setHeaderText("Plant a Crop");
     dialog.setContentText("Choose Your Crop:");
     dialog.initOwner(stage); // post the same icon from stage
     dialog.initStyle(StageStyle.UTILITY);
     //dialog.initModality(Modality.NONE);

	b.setPadding(new Insets(20));
	b.setId("settlement-node");
	b.getStylesheets().add("/fxui/css/settlementnode.css");
    b.setOnAction(e->{
        // The Java 8 way to get the response value (with lambda expression).
    	Optional<String> selected = dialog.showAndWait();
        selected.ifPresent(crop -> System.out.println("Crop added to the queue: " + crop));
    });

   //ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
   //ButtonType buttonTypeOk = new ButtonType("OK", ButtonData.OK_DONE);
   //dialog.getButtonTypes().setAll(buttonTypeCancel, buttonTypeOk);

    return b;
}
 
Example 5
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Button getIconButton(GlyphIcons icon, String styleClass, String iconSize) {
    if (icon.fontFamily().equals(MATERIAL_DESIGN_ICONS)) {
        Button iconButton = MaterialDesignIconFactory.get().createIconButton(icon,
                "", iconSize, null, ContentDisplay.CENTER);
        iconButton.setId("icon-button");
        iconButton.getGraphic().getStyleClass().add(styleClass);
        iconButton.setPrefWidth(20);
        iconButton.setPrefHeight(20);
        iconButton.setPadding(new Insets(0));
        return iconButton;
    } else {
        throw new IllegalArgumentException("Not supported icon type");
    }
}