本文整理匯總了Java中javafx.scene.layout.GridPane.setPadding方法的典型用法代碼示例。如果您正苦於以下問題:Java GridPane.setPadding方法的具體用法?Java GridPane.setPadding怎麽用?Java GridPane.setPadding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.layout.GridPane
的用法示例。
在下文中一共展示了GridPane.setPadding方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
@Override public void start(Stage stage) {
GridPane gridPane = new GridPane();
gridPane.setPadding(new Insets(10));
gridPane.setHgap(10);
gridPane.setVgap(10);
gridPane.add(lineChart, 0, 0);
gridPane.add(areaChart, 1, 0);
gridPane.add(smoothLineChart, 0, 1);
gridPane.add(smoothAreaChart, 1, 1);
gridPane.add(scatterChart, 0, 2);
gridPane.add(donutChart, 1, 2);
Scene scene = new Scene(new StackPane(gridPane));
stage.setTitle("Charts");
stage.setScene(scene);
stage.show();
timer.start();
modificationThread.start();
}
示例2: createGridPane
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private GridPane createGridPane(Label lblUserName, Label lblPassword, Label lblLanguage, Button btnLogin,
Button btnReset, Button btnRegister) {
GridPane gridPane = new GridPane();
gridPane.setPadding(new Insets(20,20,20,20));
gridPane.setHgap(5);
gridPane.setVgap(5);
gridPane.add(lblUserName, 0, 0);
gridPane.add(txtUserName, 1, 0);
gridPane.add(lblPassword, 0, 1);
gridPane.add(pf, 1, 1);
gridPane.add(btnLogin, 2, 0);
gridPane.add(btnReset, 2, 1);
gridPane.add(lblMessage, 1, 2);
gridPane.add(btnRegister, 2, 2);
gridPane.add(lblLanguage, 0, 3);
gridPane.add(createComboBox(), 1 , 3);
//Reflection for gridPane
Reflection r = new Reflection();
r.setFraction(0.7f);
gridPane.setEffect(r);
return gridPane;
}
示例3: initializeGrid
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private void initializeGrid() {
grid = new GridPane();
//grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));
grid.setMaxSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE);
ColumnConstraints c1 = new ColumnConstraints();
c1.setFillWidth(true);
c1.setHgrow(Priority.ALWAYS);
grid.getColumnConstraints().addAll(new ColumnConstraints(), c1, new ColumnConstraints());
RowConstraints r2 = new RowConstraints();
r2.setFillHeight(true);
r2.setVgrow(Priority.ALWAYS);
}
示例4: displayText
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private void displayText(final String s, final String title) {
final Scene scene = new Scene(new Pane());
String text = s;
if (s == null || s.isEmpty()) { text = "Whoops! Nothing to see here"; }
final Text textItem = new Text(text);
final Button okButton = new Button("OK");
final GridPane grid = new GridPane();
grid.setVgap(4);
grid.setHgap(10);
grid.setPadding(new Insets(5, 5, 5, 5));
grid.add(textItem, 0, 0);
grid.add(okButton, 1, 0);
final Pane root = (Pane) scene.getRoot();
root.getChildren().add(grid);
if (rootModel.darkModeProperty().get()) {
scene.getStylesheets().add("root/darkMode.css");
textItem.getStyleClass().add("text");
}
final Stage stage = new Stage();
stage.setScene(scene);
stage.setTitle(title);
stage.show();
okButton.setOnAction(e -> {
stage.close();
});
}
示例5: queenWarning
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public void queenWarning(){
Dialog<ButtonType> popup = new Dialog<>();
popup.setTitle("Ajout impossible");
ButtonType close = new ButtonType("Fermer", ButtonBar.ButtonData.RIGHT);
popup.getDialogPane().getButtonTypes().add(close);
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
popup.getDialogPane().setContent(grid);
grid.add(new Label("Vous devez jouer votre reine."), 0, 0);
popup.show();
}
示例6: init
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private void init() {
GridPane grid = new GridPane();
grid.setPadding(new Insets(GuiConstants.padding));
grid.setHgap(GuiConstants.padding);
grid.setVgap(GuiConstants.padding);
int row = 0;
row = addRow("Owner", ownerLabel, grid, row);
row = addRow("Name", nameLabel, grid, row);
row = addRow("Args", argLabel, grid, row);
row = addRow("Ret Type", retTypeLabel, grid, row);
row = addRow("Access", accessLabel, grid, row);
row = addRow("Signature", sigLabel, grid, row);
row = addRow("Parents", parentLabel, grid, row);
row = addRow("Children", childLabel, grid, row);
row = addRow("Refs In", refMethodInLabel, grid, row);
row = addRow("Refs Out", refMethodOutLabel, grid, row);
row = addRow("Fields read", refFieldReadLabel, grid, row);
row = addRow("Fields written", refFieldWriteLabel, grid, row);
row = addRow("Comment", mapCommentLabel, grid, row);
setContent(grid);
}
示例7: getDemoPane
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public GridPane getDemoPane() {
GridPane pane = new GridPane();
pane.add(framedGauge1, 0, 0);
pane.add(framedGauge2, 1, 0);
pane.add(gauge3, 2, 0);
pane.add(gauge4, 3, 0);
pane.add(gauge5, 4, 0);
pane.add(clock1, 5, 0);
pane.add(clock5, 6, 0);
pane.add(gauge22, 7, 0);
pane.add(gauge29, 8, 0);
pane.add(gauge6, 0, 1);
pane.add(gauge7, 1, 1);
pane.add(gauge8, 2, 1);
pane.add(gauge9, 3, 1);
pane.add(gauge10, 4, 1);
pane.add(clock2, 5, 1);
pane.add(gauge21, 6, 1);
pane.add(gauge23, 7, 1);
pane.add(gauge30, 8, 1);
pane.add(gauge11, 0, 2);
pane.add(gauge12, 1, 2);
pane.add(gauge13, 2, 2);
pane.add(gauge14, 3, 2);
pane.add(gauge15, 4, 2);
pane.add(clock3, 5, 2);
pane.add(clock6, 6, 2);
pane.add(clock8, 7, 2);
pane.add(gauge31, 8, 2);
pane.add(gauge16, 0, 3);
pane.add(gauge17, 1, 3);
pane.add(gauge18, 2, 3);
pane.add(gauge19, 3, 3);
pane.add(gauge20, 4, 3);
pane.add(clock4, 5, 3);
pane.add(clock7, 6, 3);
pane.add(gauge24, 7, 3);
pane.add(clock12, 8, 3);
pane.add(gauge25, 0, 4);
pane.add(gauge26, 1, 4);
pane.add(gauge27, 2, 4);
pane.add(gauge28, 4, 4);
pane.add(clock9, 5, 4);
pane.add(clock10, 6, 4);
pane.add(clock11, 7, 4);
pane.setHgap(10);
pane.setVgap(10);
pane.setPadding(new Insets(10));
for (int i = 0 ; i < 9 ; i++) {
pane.getColumnConstraints().add(new ColumnConstraints(MIN_CELL_SIZE, PREF_CELL_SIZE, MAX_CELL_SIZE));
}
for (int i = 0 ; i < 5 ; i++) {
pane.getRowConstraints().add(new RowConstraints(MIN_CELL_SIZE, PREF_CELL_SIZE, MAX_CELL_SIZE));
}
pane.setBackground(new Background(new BackgroundFill(Color.rgb(90, 90, 90), CornerRadii.EMPTY, Insets.EMPTY)));
return pane;
}
示例8: setEndingScreen
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public GridPane setEndingScreen(){
GridPane endGrid = new GridPane();
endGrid.setAlignment(Pos.CENTER);
endGrid.setHgap(10);
endGrid.setVgap(10);
endGrid.setPrefWidth(300);
endGrid.setPrefHeight(150);
endGrid.setLayoutX((WIDTH-200)/2 - endGrid.getPrefWidth()/2);
endGrid.setLayoutY(HEIGHT/2 - endGrid.getPrefHeight()/2);
endGrid.setPadding(new Insets(25, 25, 25, 25));
endGrid.setStyle("-fx-background-color: #C0C0C0;");
Text scenetitle = new Text("Gratulálok, nyertél!\n\n Lépéseid száma: " + playGround.lepes);
scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
scenetitle.setTextAlignment(TextAlignment.CENTER);
endGrid.add(scenetitle, 0, 0, 2, 1);
Button btn = new Button("Hozzáadás a toplistához");
HBox hbBtn = new HBox(10);
hbBtn.setAlignment(Pos.BOTTOM_CENTER);
hbBtn.getChildren().add(btn);
endGrid.add(hbBtn, 1, 4);
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
PlayerImp.AddToHighScore(playGround.celban,playGround.lepes,playGround.datum, playGround.jatekosneve);
endGrid.setVisible(false);
}
});
return endGrid;
}
示例9: ConnDialogResult
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public static Optional<Pair<String, String>> ConnDialogResult() {
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("建立連接");
dialog.setHeaderText("請輸入服務器的連接信息");
ButtonType loginButtonType = new ButtonType("連接", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
// Create the username and password labels and fields.
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField hostName = new TextField();
hostName.setPromptText("localhost");
hostName.setText("localhost");
TextField port = new TextField();
port.setPromptText("30232");
port.setText("30232");
grid.add(new Label("主機名: "), 0, 0);
grid.add(hostName, 1, 0);
grid.add(new Label("端口號: "), 0, 1);
grid.add(port, 1, 1);
// Enable/Disable login button depending on whether a username was entered.
// Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
// loginButton.setDisable(true);
// Do some validation (using the Java 8 lambda syntax).
// hostName.textProperty().addListener((observable, oldValue, newValue) -> {
// loginButton.setDisable(newValue.trim().isEmpty());
// });
dialog.getDialogPane().setContent(grid);
// Request focus on the username field by default.
Platform.runLater(() -> hostName.requestFocus());
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
return new Pair<>(hostName.getText(), port.getText());
}
return null;
});
return dialog.showAndWait();
}
示例10: ServerPane
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public ServerPane(Organization organization, OrganizationManagerStage oms) {
super();
this.organization = organization;
this.oms = oms;
servers = FXCollections.observableArrayList();
forceUpdateServerList();
serverTable = new TableView<>(servers);
serverTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
TableColumn<ServerView, String> nameCol = new TableColumn<>("Name");
TableColumn<ServerView, String> addressCol = new TableColumn<>("Address");
nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
addressCol.setCellValueFactory(new PropertyValueFactory<>("address"));
serverTable.getColumns().add(nameCol);
serverTable.getColumns().add(addressCol);
buttonPane = new GridPane();
buttonPane.setPadding(new Insets(10, 0, 0, 0));
buttonPane.setHgap(5);
addButton = new Button("Add Server...");
editButton = new Button("Edit selected...");
removeButton = new Button("Remove selected");
addButton.setOnAction(this::addServerAction);
editButton.setOnAction(this::editServerAction);
removeButton.setOnAction(this::removeServerAction);
editButton.setDisable(true);
removeButton.setDisable(true);
buttonPane.addRow(0, addButton, editButton, removeButton);
Label title = new Label("Servers :");
title.setPadding(new Insets(0, 0, 10, 0));
setTop(title);
setCenter(serverTable);
setBottom(buttonPane);
serverTable.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> {
if (newSelection == null) {
editButton.setDisable(true);
removeButton.setDisable(true);
} else {
editButton.setDisable(false);
removeButton.setDisable(false);
}
});
}
示例11: OrganizationManagerStage
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public OrganizationManagerStage(WebServiceProvider wsp) {
super();
this.setTitle("Organization Manager");
this.wsp = wsp;
organizationList = FXCollections.observableArrayList();
forceOrganizationListRefresh();
BorderPane borderPane = new BorderPane();
borderPane.setPadding(new Insets(15));
mainPane = borderPane;
mainScene = new Scene(mainPane);
this.setScene(mainScene);
orgas = createOrganizationTable(organizationList);
orgas.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
setupButtons();
GridPane buttonPane = new GridPane();
buttonPane.setHgap(5);
buttonPane.add(removeButton, 0, 0);
buttonPane.add(leaveButton, 1, 0);
buttonPane.add(manageButton, 2, 0);
buttonPane.add(newButton, 3, 0);
buttonPane.setPadding(new Insets(10, 0, 0, 0));
Label title = new Label("Organization list :");
title.setPadding(new Insets(0, 0, 10, 0));
borderPane.setTop(title);
borderPane.setCenter(orgas);
borderPane.setBottom(buttonPane);
// TODO : Change this. Awful way to do it.
orgas.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> {
if (newSelection == null) {
manageButton.setDisable(true);
removeButton.setDisable(true);
leaveButton.setDisable(true);
} else if (!newSelection.isOwned()) { // Not owned
manageButton.setDisable(true);
removeButton.setDisable(true);
leaveButton.setDisable(false);
} else {
manageButton.setDisable(false);
removeButton.setDisable(false);
leaveButton.setDisable(true);
}
});
}
示例12: AddServerDialog
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public AddServerDialog() {
super();
// Create the custom dialog.
this.setTitle("Add a server");
this.setHeaderText("Server informations");
// Set the button types.
ButtonType addButtonType = new ButtonType("Add server", ButtonData.OK_DONE);
this.getDialogPane().getButtonTypes().addAll(addButtonType, ButtonType.CANCEL);
// Create the username and password labels and fields.
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField serverName = new TextField();
TextField address = new TextField();
TextField port = new TextField();
PasswordField password = new PasswordField();
grid.add(new Label("Server name"), 0, 0);
grid.add(serverName, 1, 0);
grid.add(new Label("Address"), 0, 1);
grid.add(address, 1, 1);
grid.add(new Label("Port"), 0, 2);
grid.add(port, 1, 2);
grid.add(new Label("Password"), 0, 3);
grid.add(password, 1, 3);
port.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if (!newValue.matches("\\d*")) {
port.setText(newValue.replaceAll("[^\\d]", ""));
}
}
});
Node addButton = this.getDialogPane().lookupButton(addButtonType);
// Verify required inputs
// TODO not working
serverName.textProperty().addListener(new RequieredListener(addButton));
address.textProperty().addListener(new RequieredListener(addButton));
port.textProperty().addListener(new RequieredListener(addButton));
password.textProperty().addListener(new RequieredListener(addButton));
this.getDialogPane().setContent(grid);
// Convert the result to a username-password-pair when the login button is clicked.
this.setResultConverter(dialogButton -> {
try {
if (dialogButton == addButtonType) {
return new LocalServer(serverName.getText(), address.getText(), Integer.parseInt(port.getText()), password.getText());
}
} catch (NumberFormatException e) {
return null;
}
return null;
});
}
示例13: AddMemberDialog
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public AddMemberDialog(Organization organization) {
super();
this.organization = organization;
this.setTitle("Add a member");
this.setHeaderText("Search user");
ButtonType addButtonType = new ButtonType("Add selected", ButtonData.OK_DONE);
this.getDialogPane().getButtonTypes().addAll(addButtonType, ButtonType.CANCEL);
BorderPane mainPane = new BorderPane();
GridPane queryPane = new GridPane();
queryField = new TextField();
Button searchButton = new Button("Search");
searchButton.setOnAction(this::searchAction);
queryField.setOnAction(this::searchAction);
searchList = FXCollections.observableArrayList();
TableView<MemberView> searchResult = new TableView<>(searchList);
searchResult.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
TableColumn<MemberView, String> nameCol = new TableColumn<>("Name");
nameCol.setCellValueFactory(new PropertyValueFactory<>("username"));
searchResult.getColumns().add(nameCol);
queryPane.addRow(0, queryField, searchButton);
queryPane.setHgap(5);
resultCount = new Label();
queryPane.setPadding(new Insets(0, 0, 10, 0));
resultCount.setPadding(new Insets(10, 0, 0, 0));
mainPane.setTop(queryPane);
mainPane.setCenter(searchResult);
mainPane.setBottom(resultCount);
this.getDialogPane().setContent(mainPane);
this.setResultConverter(dialogButton -> {
if (dialogButton == addButtonType) {
Member result = searchResult.selectionModelProperty().get().getSelectedItem().getMember();
Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to add " + result.getUsername() + " to your organization ?");
Optional<ButtonType> answer = conf.showAndWait();
if (answer.isPresent() && answer.get() == ButtonType.OK)
return result;
else
return null;
}
return null;
});
}
示例14: GoogleCalendarCreateView
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
GoogleCalendarCreateView(Consumer<CalendarViewBean> onAccept) {
nameField = new TextField();
styleComboBox = new ComboBox<>();
styleComboBox.getItems().setAll(Calendar.Style.values());
styleComboBox.setButtonCell(new StyleCell());
styleComboBox.setCellFactory(listView -> new StyleCell());
Button acceptButton = new Button("Accept");
acceptButton.disableProperty().bind(Bindings.or(Bindings.isEmpty(nameField.textProperty()), Bindings.isNull(styleComboBox.valueProperty())));
acceptButton.setOnAction(evt -> {
if (onAccept != null) {
CalendarViewBean bean = new CalendarViewBean();
bean.setName(nameField.getText());
bean.setStyle(styleComboBox.getValue());
onAccept.accept(bean);
}
close();
});
Button cancelButton = new Button("Cancel");
cancelButton.setOnAction(evt -> close());
GridPane gridPane = new GridPane();
gridPane.add(new Label("Name"), 0, 0);
gridPane.add(nameField, 1, 0);
gridPane.add(new Label("Color"), 0, 1);
gridPane.add(styleComboBox, 1, 1);
gridPane.getStyleClass().add("center");
gridPane.setVgap(5);
gridPane.setHgap(5);
gridPane.setPadding(new Insets(10));
GridPane.setHgrow(nameField, Priority.ALWAYS);
GridPane.setHgrow(styleComboBox, Priority.ALWAYS);
ButtonBar buttonBar = new ButtonBar();
buttonBar.getButtons().addAll(acceptButton, cancelButton);
VBox bottomPane = new VBox();
bottomPane.getChildren().addAll(new Separator(), buttonBar);
bottomPane.getStyleClass().add("bottom");
bottomPane.setFillWidth(true);
bottomPane.setSpacing(10);
setCenter(gridPane);
setBottom(bottomPane);
setPadding(new Insets(15));
setPrefWidth(300);
getStylesheets().add(CalendarView.class.getResource("calendar.css").toExternalForm());
}
示例15: handleSaveAndQuitGame
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public void handleSaveAndQuitGame(int status) throws IOException{
Dialog<ButtonType> popup = new Dialog<>();
popup.setTitle("Sauvegarder et quitter la partie");
ButtonType saveAndQuit = new ButtonType("Sauvegarder et quitter", ButtonBar.ButtonData.LEFT);
ButtonType cancel = new ButtonType("Annuler", ButtonBar.ButtonData.RIGHT);
popup.getDialogPane().getButtonTypes().addAll(saveAndQuit, cancel);
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField saveName = new TextField();
String saveString;
if (core.getMode() == Consts.PVP) {
saveString = core.getPlayers()[Consts.PLAYER1].getName() + "-" + core.getPlayers()[Consts.PLAYER2].getName() + "-turn" + core.getTurn();
} else if (core.getMode() == Consts.PVAI) {
saveString = core.getPlayers()[Consts.PLAYER1].getName() + "-AI_"
+ (core.getDifficulty() == Consts.EASY ? "EASY" : core.getDifficulty() == Consts.MEDIUM ? "MEDIUM" : "HARD")
+ "-turn" + core.getTurn();
}
else{
saveString = "AI_"+ (core.getDifficulty() == Consts.EASY ? "EASY-" : core.getDifficulty() == Consts.MEDIUM ? "MEDIUM-" : "HARD-")+ core.getPlayers()[Consts.PLAYER2].getName()+"-turn" + core.getTurn();
}
saveName.setPromptText(saveString);
popup.getDialogPane().setContent(grid);
grid.add(new Label("Nom de la sauvegarde :"), 0, 0);
grid.add(saveName, 1, 0);
Optional<ButtonType> result = popup.showAndWait();
if (result.get().getButtonData() == ButtonBar.ButtonData.LEFT) {
if (!saveName.getText().equals("")) {
saveString = saveName.getText();
}
if (core.save(saveString))
takeSnapshot(saveString);
switch (status) {
case (Consts.GO_TO_MAIN):
refreshor.stop();
main.showMainMenu();
break;
case (Consts.GO_TO_LOAD):
refreshor.stop();
main.showLoadGameScreen();
break;
case (Consts.GO_TO_GAME):
relaunchGameScreen();
break;
}
}
}