本文整理匯總了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);
}