本文整理汇总了Java中javafx.scene.layout.GridPane.setHgrow方法的典型用法代码示例。如果您正苦于以下问题:Java GridPane.setHgrow方法的具体用法?Java GridPane.setHgrow怎么用?Java GridPane.setHgrow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.layout.GridPane
的用法示例。
在下文中一共展示了GridPane.setHgrow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
@Override
public AlertDialog build() {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
TextArea textArea = new TextArea();
GridPane expContent = new GridPane();
Label label = new Label("Stacktrace:");
label.setTextFill(Utils.getDefaultTextColor());
initOwner(ownerStage);
setTitle(title);
setHeaderText(header);
setContentText(message);
exception.printStackTrace(pw);
String exceptionText = sw.toString();
textArea.setText(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
getDialogPane().setExpandableContent(expContent);
return this;
}
示例2: FileSelection
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public FileSelection(File parent) {
DialogPane dialogPane = this.getDialogPane();
dialogPane.setMaxWidth(1.7976931348623157E308D);
this.directoryView = new CheckTreeView<>();
this.directoryView.setMaxWidth(1.7976931348623157E308D);
CheckBoxTreeItem<File> root = createTree(new CheckBoxTreeItem<>(parent));
root.setExpanded(true);
directoryView.setRoot(root);
GridPane.setHgrow(this.directoryView, Priority.ALWAYS);
GridPane.setFillWidth(this.directoryView, true);
this.grid = new GridPane();
this.grid.setHgap(10.0D);
this.grid.setMaxWidth(1.7976931348623157E308D);
this.grid.setAlignment(Pos.CENTER_LEFT);
dialogPane.contentTextProperty().addListener((o) -> this.updateGrid());
this.setTitle(ControlResources.getString("Dialog.confirm.title"));
dialogPane.setHeaderText(ControlResources.getString("Dialog.confirm.header"));
dialogPane.getStyleClass().add("text-input-dialog");
dialogPane.getButtonTypes().addAll(new ButtonType[] { ButtonType.APPLY, ButtonType.CANCEL });
this.updateGrid();
this.setResultConverter((dialogButton) -> {
ButtonBar.ButtonData data = dialogButton == null ? null : dialogButton.getButtonData();
return data == ButtonData.APPLY ? this.getValues() : null;
});
}
示例3: setupView
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
private void setupView() {
ImageView weatherIcon = new ImageView();
weatherIcon.setImage(weatherEvent.getForecast().getWeather().getIcon());
weatherIcon.fitWidthProperty().bind(stage.widthProperty().divide(3));
weatherIcon.fitHeightProperty().bind(stage.heightProperty().multiply(1));
GridPane.setHgrow(weatherIcon, Priority.ALWAYS);
GridPane.setVgrow(weatherIcon, Priority.ALWAYS);
GridPane.setHalignment(weatherIcon, HPos.CENTER);
GridPane.setValignment(weatherIcon, VPos.CENTER);
add(weatherIcon, 0, 0);
Text txt_weather_event = new Text();
txt_weather_event.setText(controller.getWeatherEventText());
GridPane.setHgrow(txt_weather_event, Priority.ALWAYS);
GridPane.setVgrow(txt_weather_event, Priority.ALWAYS);
GridPane.setValignment(txt_weather_event, VPos.CENTER);
add(txt_weather_event, 1, 0);
}
示例4: showException
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public static Optional<ButtonType> showException(String header, Exception e) {
Alert alert = getAlert(header, "错误信息追踪:", AlertType.ERROR);
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
String exception = stringWriter.toString();
TextArea textArea = new TextArea(exception);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane gridPane = new GridPane();
gridPane.setMaxWidth(Double.MAX_VALUE);
gridPane.add(textArea, 0, 0);
alert.getDialogPane().setExpandableContent(gridPane);
return alert.showAndWait();
}
示例5: createExceptionTextArea
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
protected static GridPane createExceptionTextArea(Throwable errorToDisplay) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
errorToDisplay.printStackTrace(pw);
String exceptionText = sw.toString();
Label label = new Label("The exception stacktrace was:");
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
return expContent;
}
示例6: updateControl
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
private void updateControl() {
pane.getChildren().clear();
pane.getColumnConstraints().clear();
// the day views
WeekDayHeaderView view = getSkinnable();
final int numberOfDays = view.getNumberOfDays();
Callback<WeekDayHeaderView, WeekDayCell> cellFactory = view.getCellFactory();
for (int i = 0; i < numberOfDays; i++) {
ColumnConstraints con = new ColumnConstraints();
con.setPercentWidth((double) 100 / (double) numberOfDays);
pane.getColumnConstraints().add(con);
WeekDayCell cell = cellFactory.call(view);
GridPane.setHgrow(cell, Priority.ALWAYS);
GridPane.setVgrow(cell, Priority.ALWAYS);
GridPane.setFillHeight(cell, true);
GridPane.setFillWidth(cell, true);
final int dayCount = i;
/*
* TODO: listener must be removed when number of days change.
*/
view.dateProperty().addListener(evt -> updateCell(cell, dayCount));
updateCell(cell, dayCount);
pane.add(cell, i, 0);
}
}
示例7: updateBackgrounds
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
private void updateBackgrounds() {
// the day views
pane.getChildren().clear();
List<ColumnConstraints> constraints = new ArrayList<>();
int numberOfDays = getSkinnable().getNumberOfDays();
for (int i = 0; i < numberOfDays; i++) {
ColumnConstraints con = new ColumnConstraints();
con.setPercentWidth((double) 100 / (double) numberOfDays);
constraints.add(con);
Region region = new Region();
region.setMaxWidth(Double.MAX_VALUE);
region.getStyleClass().add(ALL_DAY_BACKGROUND_REGION);
GridPane.setHgrow(region, Priority.ALWAYS);
GridPane.setVgrow(region, Priority.ALWAYS);
GridPane.setFillHeight(region, true);
GridPane.setFillWidth(region, true);
final int day = i;
getSkinnable().dateProperty().addListener(evt -> updateRegion(region, day));
updateRegion(region, day);
pane.add(region, i, 0);
}
pane.getColumnConstraints().setAll(constraints);
getSkinnable().requestLayout();
}
示例8: exceptionAlert
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public static ViewerAlert exceptionAlert(Throwable ex) {
ViewerAlert alert = new ViewerAlert(AlertType.ERROR);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String exceptionText = sw.toString();
Label label = new Label("The exception stacktrace was:");
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
//textArea.setFont(FontUtils.textFont);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
alert.getDialogPane().setExpandableContent(expContent);
return alert;
}
示例9: createAlertDialog
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
private void createAlertDialog(DialogObject dialog) {
Alert alert = new Alert(dialog.getType());
alert.setTitle(dialog.getTitle());
alert.setHeaderText(dialog.getHeader());
alert.setContentText(dialog.getContent());
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK) {
System.exit(0);
} else {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
dialog.getexception().printStackTrace(pw);
String exceptionText = sw.toString();
Label label = new Label("The exception stacktrace was:");
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
alert.getDialogPane().setExpandableContent(expContent);
alert.showAndWait();
}
}
示例10: showDetailedErrorAlert
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public static void showDetailedErrorAlert(String title, String content, String detaildescription, String details) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(content);
TextArea textArea = new TextArea(details);
textArea.setEditable(false);
textArea.setWrapText(true);
Label label = new Label(detaildescription);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
// Set expandable Exception into the dialog pane.
alert.getDialogPane().setExpandableContent(expContent);
alert.showAndWait();
}
示例11: showErrorDialog
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
static void showErrorDialog(Throwable ex) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error!");
alert.setHeaderText(ex.getMessage());
// Create expandable Exception.
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String exceptionText = sw.toString();
Label label = new Label("The exception stacktrace was:");
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(false);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
// Set expandable Exception into the dialog pane.
alert.getDialogPane().setContent(expContent);
alert.showAndWait();
ex.printStackTrace();
}
示例12: showExceptionDialog
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public static void showExceptionDialog (String title, String headerText, String content, Throwable e) {
//Source: http://code.makery.ch/blog/javafx-dialogs-official/
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(title);
alert.setHeaderText(headerText);
alert.setContentText(content);
// Create expandable Exception.
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
String exceptionText = sw.toString();
Label label = new Label("The exception stacktrace was:");
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
//set expandable Exception into the dialog pane.
alert.getDialogPane().setExpandableContent(expContent);
alert.showAndWait();
}
示例13: showException
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
public static Alert showException(String message, Exception ex) {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Exception");
alert.setHeaderText("Encountered an Exception");
alert.setContentText(message);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String exceptionText = sw.toString();
Label label = new Label("The exception stacktrace was:");
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
alert.getDialogPane().setExpandableContent(expContent);
return alert;
}
示例14: _setFormConstraints
import javafx.scene.layout.GridPane; //导入方法依赖的package包/类
private void _setFormConstraints(ChoiceBox<?> field) {
field.setMaxWidth(Double.MAX_VALUE);
GridPane.setHgrow(field, Priority.ALWAYS);
}
示例15: 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());
}