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

The following examples show how to use javafx.scene.control.Button#setPrefWidth() . 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: WizardStageDialog.java    From arma-dialog-creator with MIT License 9 votes vote down vote up
public WizardStageDialog(@Nullable Stage primaryStage, @Nullable String title, boolean hasHelp, @NotNull WizardStep... wizardSteps) {
	super(primaryStage, new StackPane(), title, true, true, hasHelp);


	wizardStepsReadOnly = new ReadOnlyList<>(wizardSteps);

	btnPrevious = new Button(Lang.ApplicationBundle().getString("Wizards.previous"));
	btnPrevious.setOnAction(new EventHandler<ActionEvent>() {
		@Override
		public void handle(ActionEvent event) {
			goBackwardStep();
		}
	});

	btnPrevious.setPrefWidth(GenericResponseFooter.PREFFERED_BUTTON_OK_WIDTH);
	footer.getRightContainer().getChildren().add(1, btnPrevious);
	footer.btnOk.setText(Lang.ApplicationBundle().getString("Wizards.next"));

	Collections.addAll(this.wizardSteps, wizardSteps);

	for (WizardStep step : wizardSteps) {
		addWizardStep(step);
	}
	btnPrevious.setDisable(true);
}
 
Example 2
Source File: Dialog.java    From DashboardFx with GNU General Public License v3.0 6 votes vote down vote up
private static Button createButton(ButtonType type, String text, EventHandler<MouseEvent> eventEventHandler){
    Button button = new Button(text);
    button.setCursor(Cursor.HAND);
    button.setOnMouseReleased(eventEventHandler);
    button.setPrefWidth(100);
    button.addEventHandler(MouseEvent.MOUSE_RELEASED, close);

    switch (type){
        case CANCEL:
            button.setDefaultButton(true);
            break;
        case OK:
            button.setDefaultButton(true);
            break;
    }
    return button;
}
 
Example 3
Source File: AskSaveProjectDialog.java    From arma-dialog-creator with MIT License 6 votes vote down vote up
public AskSaveProjectDialog() {
	super(ArmaDialogCreator.getPrimaryStage(), new VBox(5), null, true, true, false);
	ResourceBundle bundle = Lang.ApplicationBundle();
	setTitle(bundle.getString("Popups.SaveProject.popup_title"));

	myRootElement.getChildren().add(new Label(bundle.getString("Popups.SaveProject.message")));
	btnOk.setText(bundle.getString("Confirmation.yes"));
	Button btnNo = new Button(bundle.getString("Confirmation.no"));
	btnNo.setOnAction(event -> {
		close();
	});
	btnNo.setPrefWidth(btnOk.getPrefWidth());
	getFooter().getRightContainer().getChildren().add(1, btnNo);

	myStage.setResizable(false);
}
 
Example 4
Source File: BreakingNewsDemoView.java    From htm.java-examples with GNU Affero General Public License v3.0 6 votes vote down vote up
public SegmentedButtonBar createShowLogButton(VBox vBox) {
    Button logButton = new Button("Show Activity");
    logButton.getStyleClass().add("only");
    logButton.setStyle("-fx-font-size: 10; -fx-padding: 4 12 4 12; -fx-height: 10;");
    logButton.setPrefHeight(10);
    logButton.setPrefWidth(150);
    vBox.widthProperty().addListener((v, o, n) -> {
        logButton.setLayoutX(n.doubleValue() / 2.0 - 75);
    });
    logButton.setOnAction(e -> {
        flipStateProperty.set(state = state == FlipState.ON_FRONT ? FlipState.ON_BACK : FlipState.ON_FRONT);
        logButton.setText(state == FlipState.ON_FRONT ? "Show Activity" : "Show Fingerprints");
    });
    
    SegmentedButtonBar buttonBar3 = new SegmentedButtonBar();
    buttonBar3.getChildren().addAll(logButton);
    buttonBar3.setPrefHeight(10);
    
    return buttonBar3;
}
 
Example 5
Source File: MillionApp.java    From FXTutorials with MIT License 6 votes vote down vote up
public QuestionPane() {
    super(20);

    text.setFont(FONT);

    HBox hbox = new HBox();
    for (int i = 0; i < 4; i++) {
        Button btn = new Button();
        btn.setFont(FONT);
        btn.setPrefWidth(120);
        btn.setOnAction(event -> {
            if (btn.getText().equals(current.getCorrectAnswer())) {
                nextQuestion();
            }
            else {
                System.out.println("Incorrect");
            }
        });

        buttons.add(btn);
        hbox.getChildren().add(btn);
    }

    setAlignment(Pos.CENTER);
    getChildren().addAll(text, hbox);
}
 
Example 6
Source File: GuiFactory.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public Button getButton(String name, VBox vbox, int width)
{
  Button button = new Button(name);
  button.setPrefWidth(width);
  vbox.getChildren().add(button);
  button.setDisable(true);
  return button;
}
 
Example 7
Source File: GuiFactory.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public Button getButton(String name, HBox hbox, int width)
{
  Button button = new Button(name);
  button.setPrefWidth(width);
  hbox.getChildren().add(button);
  button.setDisable(true);
  return button;
}
 
Example 8
Source File: ADCStandaloneProgressWindow.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
public void addExitButton(@NotNull String exitBtnText) {
	if (exitButtonAdded) {
		return;
	}
	exitButtonAdded = true;
	final Button btnExit = new Button(exitBtnText);
	btnExit.setPrefWidth(120d);
	btnExit.setOnAction(new EventHandler<ActionEvent>() {
		@Override
		public void handle(ActionEvent event) {
			Platform.exit();
		}
	});
	root.getChildren().add(btnExit);
}
 
Example 9
Source File: GenericResponseFooter.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
public GenericResponseFooter(boolean addCancel, boolean addOk, boolean addHelpButton, EventHandler<ActionEvent> helpEvent, EventHandler<ActionEvent> cancelEvent, EventHandler<ActionEvent> okEvent
) {
	rightContainer = new HBox(5);
	if (addHelpButton) {
		btnHelp = new Button(Lang.ApplicationBundle().getString("Popups.btn_help"));
		btnHelp.setTooltip(new Tooltip(Lang.ApplicationBundle().getString("Popups.btn_help_tooltip")));
		btnHelp.setOnAction(helpEvent);
		btnHelp.setPrefWidth(50d);
		setLeft(btnHelp);
	} else {
		btnHelp = null;
	}
	if (addCancel) {
		btnCancel = new Button(Lang.ApplicationBundle().getString("Popups.btn_cancel"));
		btnCancel.setOnAction(cancelEvent);
		btnCancel.setPrefWidth(PREFFERED_BUTTON_CANCEL_WIDTH);
		rightContainer.getChildren().add(btnCancel);
	} else {
		btnCancel = null;
	}
	if (addOk) {
		btnOk = new Button(Lang.ApplicationBundle().getString("Popups.btn_ok"));
		btnOk.setOnAction(okEvent);
		btnOk.setPrefWidth(PREFFERED_BUTTON_OK_WIDTH);
		rightContainer.getChildren().add(btnOk);
	} else {
		btnOk = null;
	}

	rightContainer.setAlignment(Pos.BOTTOM_RIGHT);
	rightContainer.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
	setRight(rightContainer);
	setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
}
 
Example 10
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");
    }
}
 
Example 11
Source File: RichTextDemo.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Button createButton(String styleClass, Runnable action, String toolTip) {
    Button button = new Button();
    button.getStyleClass().add(styleClass);
    button.setOnAction(evt -> {
        action.run();
        area.requestFocus();
    });
    button.setPrefWidth(25);
    button.setPrefHeight(25);
    if (toolTip != null) {
        button.setTooltip(new Tooltip(toolTip));
    }
    return button;
}