本文整理匯總了Java中javafx.scene.layout.GridPane.setHgap方法的典型用法代碼示例。如果您正苦於以下問題:Java GridPane.setHgap方法的具體用法?Java GridPane.setHgap怎麽用?Java GridPane.setHgap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.layout.GridPane
的用法示例。
在下文中一共展示了GridPane.setHgap方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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("Type", typeLabel, 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("Read refs", readRefLabel, grid, row);
row = addRow("Write refs", writeRefLabel, grid, row);
row = addRow("Comment", mapCommentLabel, grid, row);
setContent(grid);
}
示例2: start
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
WatchDAO.addWatcher(this);
stage = primaryStage;
stage.setTitle(ViewConstants.PROGRAM_TITLE);
stage.getIcons().add(fileLoad.loadImageFile(ViewConstants.PROGRAM_ICON_LOCATION));
gridPane = new GridPane();
gridPane.setAlignment(Pos.TOP_LEFT);
gridPane.setHgap(10);
gridPane.setVgap(10);
gridPane.setPadding(new Insets(10, 10, 10, 10));
Scene scene = new Scene(gridPane, ViewConstants.PROGRAM_WIDTH, ViewConstants.PROGRAM_HEIGHT);
primaryStage.setScene(scene);
primaryStage.show();
gridPane.getStylesheets().add(this.getClass().getClassLoader().getResource("gui/css/weatherwatch.css")
.toExternalForm());
loadWeatherImages();
addGuiElements();
TrayApp.initialize();
}
示例3: 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();
}
示例4: initGridPane
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private GridPane initGridPane() {
GridPane gridPane = new GridPane();
//
TextField faddress = new TextField();
faddress.setPromptText("Enter server adders");
faddress.setOnAction(s -> client.makeConnection(faddress.getText()));
//text field init
TextField textField = new TextField();
textField.setPromptText("Enter command");
textField.setOnAction(s -> {
process(textField.getText());
textField.setText("");
});
//btn
Button button = new Button("Connect");
button.setOnAction(s -> client.makeConnection(faddress.getText()));
gridPane.add(button, 0, 0);
gridPane.add(faddress, 1, 0, 1, 1);
gridPane.add(clientConsole.view, 0, 1, 2, 1);
gridPane.add(textField, 0, 2, 2, 1);
gridPane.setAlignment(Pos.CENTER);
//grid settings
gridPane.setHgap(10);
gridPane.setVgap(10);
return gridPane;
}
示例5: getGridPane
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public GridPane getGridPane() {
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(10, 10, 10, 10));
return grid;
}
示例6: ToggleButtonSample
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public ToggleButtonSample() {
// create label to show result of selected toggle button
final Label label = new Label();
label.setStyle("-fx-font-size: 2em;");
// create 3 toggle buttons and a toogle group for them
final ToggleButton tb1 = new ToggleButton("Cat");
final ToggleButton tb2 = new ToggleButton("Dog");
final ToggleButton tb3 = new ToggleButton("Horse");
ToggleGroup group = new ToggleGroup();
tb1.setToggleGroup(group);
tb2.setToggleGroup(group);
tb3.setToggleGroup(group);
group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
@Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle selectedToggle) {
if(selectedToggle!=null) {
label.setText(((ToggleButton) selectedToggle).getText());
}
else {
label.setText("...");
}
}
});
// select the first button to start with
group.selectToggle(tb1);
// add buttons and label to grid and set their positions
GridPane.setConstraints(tb1,0,0);
GridPane.setConstraints(tb2,1,0);
GridPane.setConstraints(tb3,2,0);
GridPane.setConstraints(label,0,1,3,1);
GridPane grid = new GridPane();
grid.setVgap(20);
grid.setHgap(10);
getChildren().add(grid);
grid.getChildren().addAll(tb1, tb2, tb3, label);
}
示例7: ResponseDeviceStatusResult
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public static Optional<TcpMsgResponseDeviceStatus> ResponseDeviceStatusResult() throws NumberFormatException {
Dialog<TcpMsgResponseDeviceStatus> 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 textFieldGroupId = new TextField();
textFieldGroupId.setPromptText("1 - 120");
TextField textFieldDeviceId = new TextField();
textFieldDeviceId.setPromptText("1 - 100");
TextField textFieldStatus = new TextField();
textFieldStatus.setPromptText("1 - 6");
grid.add(new Label("組號: "), 0, 0);
grid.add(textFieldGroupId, 1, 0);
grid.add(new Label("設備號: "), 0, 1);
grid.add(textFieldDeviceId, 1, 1);
grid.addRow(2, new Label("狀態碼: "));
// grid.add(, 0, 2);
grid.add(textFieldStatus, 1, 2);
// 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).
textFieldGroupId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus)));
textFieldDeviceId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus)));
textFieldStatus.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus)));
dialog.getDialogPane().setContent(grid);
// Request focus on the username field by default.
Platform.runLater(textFieldGroupId::requestFocus);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
try {
TcpMsgResponseDeviceStatus tcpMsgResponseDeviceStatus = new TcpMsgResponseDeviceStatus(Integer.parseInt(
textFieldGroupId.getText().trim()),
Integer.parseInt(textFieldDeviceId.getText().trim()),
Integer.parseInt(textFieldStatus.getText().trim()));
return tcpMsgResponseDeviceStatus;
} catch (NumberFormatException e) {
System.out.println("空");
return new TcpMsgResponseDeviceStatus(-1, -1, -1);
}
}
return null;
});
return dialog.showAndWait();
}
示例8: createPredefinedTagsGrid
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private GridPane createPredefinedTagsGrid() {
final GridPane grid = new GridPane();
grid.setHgap(GRID_GAP);
grid.setVgap(GRID_GAP);
grid.setPadding(new Insets(GRID_GAP));
grid.setGridLinesVisible(false);
//-------------------------------------------------------------------- Column #0
//
final Label idLabel = new Label("ID");
grid.add(idLabel, 0, 0);
GridPane.setHalignment(idLabel, HPos.RIGHT);
//
final Label nameLabel = new Label("Name");
grid.add(nameLabel, 0, 1);
GridPane.setHalignment(nameLabel, HPos.RIGHT);
//
final Label titleLabel = new Label("Title");
grid.add(titleLabel, 0, 2);
GridPane.setHalignment(titleLabel, HPos.RIGHT);
//
//-------------------------------------------------------------------- Column #1
//
grid.add(ID_TAG_FIELD, 1, 0);
grid.add(NAME_TAG_FIELD, 1, 1);
grid.add(TITLE_TAG_FIELD, 1, 2);
//
//-------------------------------------------------------------------- Constraints
//
for (int i = 0; i < 2; i++) {
final ColumnConstraints column = new ColumnConstraints();
column.setFillWidth(true);
column.setHgrow(Priority.NEVER);
grid.getColumnConstraints().add(column);
}
for (int i = 0; i < 3; i++) {
final RowConstraints row = new RowConstraints();
row.setFillHeight(true);
row.setVgrow(Priority.NEVER);
grid.getRowConstraints().add(row);
}
//
grid.getColumnConstraints().get(1).setHgrow(Priority.SOMETIMES);
//
//-------------------------------------------------------------------- Style
//
ID_TAG_FIELD.setStyle(READ_ONLY_STYLE);
NAME_TAG_FIELD.setStyle(READ_ONLY_STYLE);
TITLE_TAG_FIELD.setStyle(READ_ONLY_STYLE);
//
//-------------------------------------------------------------------- Editable
//
ID_TAG_FIELD.setEditable(false);
NAME_TAG_FIELD.setEditable(false);
TITLE_TAG_FIELD.setEditable(false);
//
return grid;
}
示例9: MemberPane
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public MemberPane(Organization organization, EditOrganizationStage oms) {
super();
this.organization = organization;
this.eos = oms;
members = FXCollections.observableArrayList();
forceUpdateMemberList();
memberTable = new TableView<>(members);
TableColumn<MemberView, String> nameCol = new TableColumn<>("Name");
nameCol.setCellValueFactory(new PropertyValueFactory<>("username"));
ColumnConstraints cc = new ColumnConstraints();
cc.setPercentWidth(100);
memberTable.getColumns().add(nameCol);
memberTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
buttonPane = new GridPane();
buttonPane.setPadding(new Insets(10, 0, 0, 0));
buttonPane.setHgap(5);
addMember = new Button("Add Member...");
removeMember = new Button("Remove selected");
transfertOwnership = new Button("Transfert Ownership");
buttonPane.addRow(0, addMember, removeMember, transfertOwnership);
addMember.setOnAction(this::addMemberAction);
removeMember.setOnAction(this::removeMemberAction);
transfertOwnership.setOnAction(this::transferOwnershipAction);
removeMember.setDisable(true);
transfertOwnership.setDisable(true);
Label title = new Label("Members :");
title.setPadding(new Insets(0, 0, 10, 0));
setTop(title);
setCenter(memberTable);
setBottom(buttonPane);
memberTable.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> {
if (newSelection == null || newSelection.isYou()) {
removeMember.setDisable(true);
transfertOwnership.setDisable(true);
} else {
removeMember.setDisable(false);
transfertOwnership.setDisable(false);
}
});
}
示例10: getNode
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
@Override
public Node getNode() {
// TODO Auto-generated method stub
GridPane grid = new GridPane();
grid.setMinSize(30, 500);
grid.setHgap(5);
//TODO: add a small map
//grid.add(getSmallMap(), 0, 0);
grid.add(getSelectedSpriteButton(), 1, 0);
grid.add(getAllSpritesButton(), 2, 0);
grid.add(getSkillsButton(), 3, 0);
return grid;
}
示例11: ShtoPunetor
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public ShtoPunetor(DritarjaKryesore dk, String dump){
stage.getIcons().add(new Image(getClass().getResourceAsStream("/sample/foto/icon.png")));
stage.setTitle("Ndrysho fjalekalimin");
stage.initModality(Modality.APPLICATION_MODAL);
stage.setResizable(false);
HBox btn = new HBox(5);
btn.setAlignment(Pos.CENTER_RIGHT);
btn.getChildren().addAll(btnOk, btnAnulo);
data.setValue(LocalDate.now());
GridPane root = new GridPane();
root.add(new Label("Emri"), 0, 0);
root.add(user, 1, 0);
root.add(new Label("Fjalekalimi"), 0, 1);
root.add(pw, 1, 1);
root.add(shfaq, 2, 1);
root.add(lblPw, 1, 2);
root.add(btn, 1, 4);
shfaq.setGraphic(new ImageView(new Image("/sample/foto/eye.png")));
shfaq.setOnMousePressed(e -> lblPw.setText(pw.getText()));
shfaq.setOnMouseReleased(e -> lblPw.setText(""));
user.setText(dk.log_user.getText());
pw.setText(dk.log_pw.getText());
user.setEditable(false);
user.setTooltip(new Tooltip("Emri nuk mund te ndryshohet"));
btnOk.setOnAction(e -> {
if (pw.getText().length() > 5){
rregullo(Integer.parseInt(dk.lblId.getText()));
}else new Mesazhi("Info", "Fjalekalimi i shkurte", "Fjalekalimi duhet te jete mbi 5 karaktere i gjate.");
});
btnAnulo.setOnAction(e -> stage.close());
pw.setOnKeyPressed(e -> {if (e.getCode().equals(KeyCode.ENTER)){
if (pw.getText().length() > 5)
rregullo(Integer.parseInt(dk.lblId.getText()));
else new Mesazhi("Info", "Fjalekalimi i shkurte", "Fjalekalimi duhet te jete mbi 5 karaktere i gjate.");
}});
emri.setOnKeyPressed(e -> {if (e.getCode().equals(KeyCode.ENTER)){
if (pw.getText().length() > 5)
rregullo(Integer.parseInt(dk.lblId.getText()));
else new Mesazhi("Info", "Fjalekalimi i shkurte", "Fjalekalimi duhet te jete mbi 5 karaktere i gjate.");
}});
root.setVgap(7);
root.setHgap(5);
root.setAlignment(Pos.CENTER);
Scene scene = new Scene(root, 320, 210);
scene.getStylesheets().add(getClass().getResource("/sample/style.css").toExternalForm());
stage.setScene(scene);
stage.show();
}
示例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: BanDialog
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public BanDialog(String playerName, String defaultReason, int defaultDuration) {
super();
// Create the custom dialog.
this.setTitle("Ban dialog");
this.setHeaderText("Do you really want to ban " + playerName + " ?");
// Set the button types.
ButtonType loginButtonType = new ButtonType("OK", ButtonData.OK_DONE);
this.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 reason = new TextField();
reason.setText(defaultReason);
TextField duration = new TextField();
duration.setText(defaultDuration+"");
duration.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if (!newValue.matches("\\d*")) {
duration.setText(newValue.replaceAll("[^\\d]", ""));
}
}
});
grid.add(new Label("Reason"), 0, 0);
grid.add(reason, 1, 0);
grid.add(new Label("Duration, in days (0 = perm)"), 0, 1);
grid.add(duration, 1, 1);
Node loginButton = this.getDialogPane().lookupButton(loginButtonType);
reason.textProperty().addListener((observable, oldValue, newValue) -> {
loginButton.setDisable(newValue.trim().isEmpty());
});
this.getDialogPane().setContent(grid);
this.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
return new Pair<>(reason.getText(), Integer.parseInt(duration.getText()));
}
return null;
});
}
示例15: ASMCreationPanel
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
/**
* @param onCreateASM
* Method to call when "create" is clicked. This parameter must be
* non-null.
*
* @throws IllegalArgumentException
* if onCreateASM is null
*/
public ASMCreationPanel(Consumer<ASMCreationDetails> onCreateASM)
{
if (onCreateASM == null)
throw new IllegalArgumentException("onCreateASM must be non-null");
this.onCreateASM = onCreateASM;
this.setPadding(new Insets(20));
GridPane grid = new GridPane();
HBox buttons = new HBox(10);
grid.setHgap(10);
grid.setVgap(30);
grid.setPadding(new Insets(10, 10, 10, 10));
Label ASMFileName = new Label();
ASMFileName.setText("File Name: ");
ASMFileName.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
nameText = new TextField();
nameText.setText("");
nameText.requestFocus();
nameText.setPrefWidth(200);
Label projectName = new Label();
projectName.setText("Add to Project: ");
projectName.setFont(Font.font("Arial", FontWeight.NORMAL, 16));
projectListDropdown = new ComboBox<>();
Button create = new Button();
create.setText("Create");
create.setOnAction(this::onCreateASMClicked);
grid.add(ASMFileName, 0, 0);
grid.add(nameText, 1, 0);
grid.add(projectName, 0, 1);
grid.add(projectListDropdown, 1, 1);
this.setCenter(grid);
buttons.getChildren().add(create);
buttons.setAlignment(Pos.BASELINE_RIGHT);
this.setBottom(buttons);
}