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

The following examples show how to use javafx.scene.control.Button#setPrefSize() . 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: Slide.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
protected Button addSlideControlButton(String text, final EventHandler<ActionEvent> eventHandler) {
	if (controlNodes.size() >= MAX_CONTROL_BUTTONS) {
		throw new AssertionError("The slide already has the maximum number of control buttons");
	}

	final Button controlButton = new Button(text);
	controlButton.setPrefSize(CONTROL_BUTTON_WIDTH, CONTROL_BUTTON_HEIGHT);
	controlButton.setOnAction(eventHandler);
	controlNodes.add(controlButton);

	return controlButton;
}
 
Example 2
Source File: BillBoardBehaviorTest.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
private void createOverlay(){
    Button b = new Button("Activate");
    b.setPrefSize(150, 40);
    b.setFocusTraversable(false);
    b.setOnAction(e->{
        if(!active){
            bill.startBillboardBehavior();
            active = true;
            b.setText("Disable");
        }else{
            bill.stopBillboardBehavior();
            active = false;
            b.setText("Enable");
        }
    });
    CheckBox c = new CheckBox("Toggle Cylindrical Mode");
    c.setFont(Font.font(24));
    c.setFocusTraversable(false);
    c.setOnAction(e->{
        if(c.isSelected()){
            bill.setBillboardMode(BillboardBehavior.BillboardMode.CYLINDRICAL);
        }else{
            bill.setBillboardMode(BillboardBehavior.BillboardMode.SPHERICAL);
        }
    });
    
    StackPane.setAlignment(b, Pos.TOP_LEFT);
    StackPane.setMargin(b, new Insets(10));
    
    StackPane.setAlignment(c, Pos.CENTER_LEFT);
    StackPane.setMargin(c, new Insets(10));
    
    rootPane.getChildren().addAll(b, c);
}
 
Example 3
Source File: AbstractProtocolView.java    From trex-stateless-gui with Apache License 2.0 3 votes vote down vote up
/**
 *
 * @param input
 * @param top
 * @param left
 * @param width
 */
protected void addButton(Button input, double top, double left, double width) {
    input.setPrefSize(width, 22);
    container.getChildren().add(input);
    container.setTopAnchor(input, top);
    container.setLeftAnchor(input, left);
}
 
Example 4
Source File: TrainingExerciseBase.java    From ShootOFF with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Adds a button to the right of the reset button on the main ShootOFF
 * window with caption <tt>text</tt> and action handler
 * <tt>eventHandler</tt>.
 * 
 * @param text
 *            the caption to display on the new button
 * 
 * @param eventHandler
 *            the event handler that performs actions when this new button
 *            is clicked
 * 
 * @return the new button that was added to the main ShootOFF window
 */
public Button addShootOFFButton(final String text, final EventHandler<ActionEvent> eventHandler) {
	final Button exerciseButton = new Button(text);
	final Button resetButton = (Button) buttonsContainer.getChildren().get(0);
	exerciseButton.setOnAction(eventHandler);
	exerciseButton.setPrefSize(resetButton.getPrefWidth(), resetButton.getPrefHeight());
	exerciseButtons.add(exerciseButton);

	buttonsContainer.getChildren().add(exerciseButton);

	return exerciseButton;
}