本文整理汇总了Java中javafx.scene.control.Button.setPrefSize方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setPrefSize方法的具体用法?Java Button.setPrefSize怎么用?Java Button.setPrefSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Button
的用法示例。
在下文中一共展示了Button.setPrefSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ButtonControl
import javafx.scene.control.Button; //导入方法依赖的package包/类
public ButtonControl(String name) {
super(name, FlashboardSendableType.ACTIVATABLE);
node = new HBox();
node.setAlignment(Pos.CENTER);
button = new Button(name);
button.setPrefSize(WIDTH, HEIGHT);
button.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event) {
press();
button.setDisable(true);
}
});
node.getChildren().add(button);
button.setAlignment(Pos.CENTER);
}
示例2: load
import javafx.scene.control.Button; //导入方法依赖的package包/类
private void load(String fxml, String buttonName, Image background, boolean showDefault) {
Parent parent = null;
try {
parent = FXMLLoader.load(Main.class.getResource("/fxml/" + fxml + ".fxml"));
panes.put(fxml, parent);
ImageView imageView = new ImageView(background);
imageView.setFitHeight(30);
imageView.setFitWidth(30);
Button button = new Button(buttonName, imageView);
button.setAlignment(Pos.BASELINE_LEFT);
button.setPrefSize(200, 50);
button.setStyle("-fx-border-width: 0;");
InterfaceManager.addInterface(Container.create(fxml, button));
if (showDefault) FrameController.instance.pane.getChildren().add(getInstance(fxml));
} catch (IOException e) {
e.printStackTrace();
}
}
示例3: buildMainMenu
import javafx.scene.control.Button; //导入方法依赖的package包/类
private void buildMainMenu(Group root, Scene scene, Dimension screenSize) {
// Main title
Label maintitle = new Label();
maintitle.setText("Chess Master");
maintitle.setFont(new Font("Arial", MAIN_TITLE_FONT_SIZE));
maintitle.setLayoutX(MAIN_TITLE_LEFT_PADDING);
maintitle.setLayoutY(MAIN_TITLE_TOP_PADDING);
root.getChildren().add(maintitle);
// Buttons
Group buttonsGroup = new Group();
// Start button.
Button choiceGameButton = new Button();
choiceGameButton.setLayoutX(screenSize.getWidth() * BUTTON_LEFT_PADDING);
choiceGameButton.setLayoutY(maintitle.getLayoutY() * 2);
choiceGameButton.setPrefSize(BUTTONS_WIDTH, BUTTONS_HEIGHT);
choiceGameButton.setText("Choose your game");
buttonsGroup.getChildren().add(choiceGameButton);
// Setting button.
Button settingButton = new Button();
settingButton.setLayoutX(screenSize.getWidth() * BUTTON_LEFT_PADDING);
settingButton.setLayoutY(choiceGameButton.getLayoutY() + BUTTONS_SPACE);
settingButton.setPrefSize(BUTTONS_WIDTH, BUTTONS_HEIGHT);
settingButton.setText("Settings");
buttonsGroup.getChildren().add(settingButton);
// Quit button.
Button quitButton = new Button();
quitButton.setLayoutX(screenSize.getWidth() * BUTTON_LEFT_PADDING);
quitButton.setLayoutY(settingButton.getLayoutY() + BUTTONS_SPACE);
quitButton.setPrefSize(BUTTONS_WIDTH, BUTTONS_HEIGHT);
quitButton.setText("Quit game");
quitButton.setOnAction(handle -> closeApp());
buttonsGroup.getChildren().add(quitButton);
root.getChildren().add(buttonsGroup);
// Copyright
Label copyright = new Label();
copyright.setText("All rights reserved, Nicolas GILLE, 2017");
copyright.setFont(new Font("Arial", 12));
copyright.setLayoutX(COPYRIGHT_LEFT_PADDING);
copyright.setLayoutY(COPYRIGHT_TOP_PADDING);
root.getChildren().add(copyright);
}
示例4: createButton
import javafx.scene.control.Button; //导入方法依赖的package包/类
private Button createButton(String text) {
Button btn = new Button(text);
btn.setPrefSize(BUTTON_SIZE, BUTTON_SIZE);
btn.getStyleClass().add("task-list-button");
return btn;
}
示例5: create
import javafx.scene.control.Button; //导入方法依赖的package包/类
static Container create(String fxmlName) throws IOException {
Button button = new Button(fxmlName);
button.setPrefSize(200, 50);
return create(fxmlName, button);
}