本文整理匯總了Java中javafx.scene.layout.GridPane.setHalignment方法的典型用法代碼示例。如果您正苦於以下問題:Java GridPane.setHalignment方法的具體用法?Java GridPane.setHalignment怎麽用?Java GridPane.setHalignment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.layout.GridPane
的用法示例。
在下文中一共展示了GridPane.setHalignment方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: content
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
protected GridPane content() {
gridP.setHgap(8);
gridP.setVgap(6);
gridP.setPadding(new Insets(10, 20, 12, 20));
gridP.add(header, 0, 0, 2, 1);
gridP.add(useProxyL, 0, 1);
gridP.add(useProxy, 1, 1);
gridP.add(hostL, 0, 2);
gridP.add(host, 1, 2, 2, 1);
gridP.add(portL, 0, 3);
gridP.add(port, 1, 3, 2, 1);
GridPane.setHalignment(okBtn, HPos.RIGHT);
GridPane.setHalignment(cancelBtn, HPos.RIGHT);
okBtn.setPrefWidth(80);
cancelBtn.setPrefWidth(80);
gridP.add(okBtn, 1, 4);
gridP.add(cancelBtn, 2, 4);
return gridP;
}
示例2: content
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
protected GridPane content() {
gridP.setHgap(8);
gridP.setVgap(6);
gridP.setPadding(new Insets(10, 20, 12, 20));
gridP.add(header, 0, 0, 2, 1);
gridP.add(mailmanNameL, 0, 2);
gridP.add(mailmanName, 1, 2, 2, 1);
gridP.add(mailmanLastNameL, 0, 1);
gridP.add(mailmanLastName, 1, 1, 2, 1);
gridP.add(driverL, 0, 3);
gridP.add(driver, 1, 3);
GridPane.setHalignment(okBtn, HPos.RIGHT);
GridPane.setHalignment(cancelBtn, HPos.RIGHT);
okBtn.setPrefWidth(80);
cancelBtn.setPrefWidth(80);
gridP.add(okBtn, 1, 4);
gridP.add(cancelBtn, 2, 4);
return gridP;
}
示例3: content
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
protected GridPane content() {
gridP.setHgap(8);
gridP.setVgap(6);
gridP.setPadding(new Insets(10, 20, 12, 20));
gridP.add(header, 0, 0, 2, 1);
gridP.add(addressStreetL, 0, 1);
gridP.add(addressStreet, 1, 1, 2, 1);
gridP.add(addressCityL, 0, 2);
gridP.add(addressCity, 1, 2, 2, 1);
gridP.add(drivenL, 0, 3);
gridP.add(driven, 1, 3);
GridPane.setHalignment(okBtn, HPos.RIGHT);
GridPane.setHalignment(cancelBtn, HPos.RIGHT);
okBtn.setPrefWidth(80);
cancelBtn.setPrefWidth(80);
gridP.add(okBtn, 1, 4);
gridP.add(cancelBtn, 2, 4);
return gridP;
}
示例4: start
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
@Override public void start(Stage stage) {
GridPane pane = new GridPane();
Label nonInteractive = new Label("Non Interactive");
Label interactive = new Label("Interactive");
pane.add(nonInteractive, 0, 0);
pane.add(nonInteractiveSunburstChart, 0, 1);
pane.add(interactive, 1, 0);
pane.add(interactiveSunburstChart, 1, 1);
GridPane.setHalignment(nonInteractive, HPos.CENTER);
GridPane.setHalignment(interactive, HPos.CENTER);
pane.setPadding(new Insets(10));
Scene scene = new Scene(pane);
stage.setTitle("JavaFX Sunburst Chart");
stage.setScene(scene);
stage.show();
interactiveSunburstChart.setAutoTextColor(true);
//timer.start();
// Calculate number of nodes
calcNoOfNodes(nonInteractiveSunburstChart);
System.out.println(noOfNodes + " Nodes in non interactive Sunburst Chart");
noOfNodes = 0;
calcNoOfNodes(interactiveSunburstChart);
System.out.println(noOfNodes + " Nodes in interactive Sunburst Chart");
}
示例5: addString
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
/**
* Add a simple String to a wizard step.
*
* @param fieldName
* @param defaultValue
* the default String the textfield will contains.
* @param prompt
* the text to show on the textfield prompt String.
* @param isRequired
* set the field required to continue
* @return
*/
@SuppressWarnings("unchecked")
public WizardStepBuilder addString(final String fieldName, final String defaultValue, final String prompt,
final boolean isRequired)
{
final JFXTextField text = new JFXTextField();
text.setPromptText(prompt);
if (isRequired)
{
final RequiredFieldValidator validator = new RequiredFieldValidator();
validator.setMessage(Translation.LANG.getTranslation("wizard.error.input_required"));
validator.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em")
.styleClass("error").build());
text.getValidators().add(validator);
}
text.focusedProperty().addListener((o, oldVal, newVal) ->
{
if (!newVal)
text.validate();
});
text.setText(defaultValue);
this.current.getData().put(fieldName, new SimpleStringProperty());
this.current.getData().get(fieldName).bind(text.textProperty());
this.current.addToValidate(text);
final Label label = new Label(fieldName);
GridPane.setHalignment(label, HPos.RIGHT);
GridPane.setHalignment(text, HPos.LEFT);
this.current.add(label, 0, this.current.getData().size() - 1);
this.current.add(text, 1, this.current.getData().size() - 1);
return this;
}
示例6: setupView
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private void setupView() {
setHgap(10);
setVgap(10);
forecastOnePane = new ForecastDisplayPane(stage, forecastOne);
GridPane.setHalignment(forecastOnePane, HPos.CENTER);
GridPane.setHgrow(forecastOnePane, Priority.ALWAYS);
GridPane.setVgrow(forecastOnePane, Priority.ALWAYS);
forecastTwoPane = new ForecastDisplayPane(stage, forecastTwo);
GridPane.setHalignment(forecastTwoPane, HPos.CENTER);
GridPane.setHgrow(forecastTwoPane, Priority.ALWAYS);
GridPane.setVgrow(forecastTwoPane, Priority.ALWAYS);
forecastThreePane = new ForecastDisplayPane(stage, forecastThree);
GridPane.setHalignment(forecastThreePane, HPos.CENTER);
GridPane.setHgrow(forecastThreePane, Priority.ALWAYS);
GridPane.setVgrow(forecastThreePane, Priority.ALWAYS);
Platform.runLater(new Runnable() {
@Override
public void run() {
getChildren().clear();
add(forecastOnePane, 0, 0);
add(forecastTwoPane, 1, 0);
add(forecastThreePane, 2, 0);
}
});
}
示例7: addToggleGroup
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
/**
* Add an enumeration of options to a wizard step. Multiple RadioButtons
* will be used (horizontally-aligned).
*
* @param fieldName
* @param options
* list of choices.
* @param prompt
* the text to show on the buttons tooltip.
* @param defaultValue
* the default value to be selected.
* @return
*/
@SuppressWarnings("unchecked")
public WizardStepBuilder addToggleGroup(final String fieldName, final String[] options, final String[] prompt,
final int defaultValue)
{
final ToggleGroup group = new ToggleGroup();
final HBox box = new HBox();
for (int i = 0; i < options.length; i++)
{
final JFXRadioButton radio = new JFXRadioButton(options[i]);
radio.setPadding(new Insets(10));
radio.setToggleGroup(group);
radio.setTooltip(new Tooltip(prompt[i]));
radio.setUserData(options[i]);
if (i == defaultValue)
radio.setSelected(true);
box.getChildren().add(radio);
}
this.current.getData().put(fieldName, new ReadOnlyObjectWrapper<Toggle>());
this.current.getData().get(fieldName).bind(group.selectedToggleProperty());
final Label label = new Label(fieldName);
GridPane.setHalignment(label, HPos.RIGHT);
GridPane.setHalignment(box, HPos.LEFT);
this.current.add(label, 0, this.current.getData().size() - 1);
this.current.add(box, 1, this.current.getData().size() - 1);
return this;
}
示例8: addFileChooser
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public WizardStepBuilder addFileChooser(final String fieldName, final String fileChooseLabel, final String startDir,
final FileChooser.ExtensionFilter... filters)
{
final WizardStep current = this.current;
final HBox box = new HBox();
final JFXButton button = new JFXButton(fileChooseLabel);
button.setStyle("-fx-text-fill: BLACK;-fx-font-size: 18px;-fx-opacity: 0.7;");
final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(fileChooseLabel);
fileChooser.setInitialDirectory(new File(startDir));
fileChooser.getExtensionFilters().addAll(filters);
this.current.getData().put(fieldName, new SimpleObjectProperty<File>());
button.setOnAction(
e -> current.getData().get(fieldName).setValue(fileChooser.showOpenDialog(MineIDE.primaryStage)));
final Label label = new Label(fieldName);
GridPane.setHalignment(label, HPos.RIGHT);
GridPane.setHalignment(button, HPos.LEFT);
this.current.add(label, 0, this.current.getData().size() - 1);
final JFXTextField text = new JFXTextField();
text.setEditable(false);
this.current.getData().get(fieldName).addListener(
(ChangeListener<File>) (observable, oldValue, newValue) -> text.setText(newValue.getAbsolutePath()));
box.getChildren().addAll(text, button);
this.current.add(box, 1, this.current.getData().size() - 1);
return this;
}
示例9: start
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
@Override public void start(Stage stage) {
GridPane pane = new GridPane();
Label nonInteractive = new Label("Non Interactive");
Label interactive = new Label("Interactive");
pane.add(nonInteractive, 0, 0);
pane.add(nonInteractiveSunburstChart, 0, 1);
pane.add(interactive, 1, 0);
pane.add(interactiveSunburstChart, 1, 1);
GridPane.setHalignment(nonInteractive, HPos.CENTER);
GridPane.setHalignment(interactive, HPos.CENTER);
pane.setPadding(new Insets(10));
Scene scene = new Scene(pane);
stage.setTitle("Sunburst Chart");
stage.setScene(scene);
stage.show();
interactiveSunburstChart.setAutoTextColor(true);
//timer.start();
// Calculate number of nodes
calcNoOfNodes(nonInteractiveSunburstChart);
System.out.println(noOfNodes + " Nodes in non interactive Sunburst Chart");
noOfNodes = 0;
calcNoOfNodes(interactiveSunburstChart);
System.out.println(noOfNodes + " Nodes in interactive Sunburst Chart");
}
示例10: createGridRow
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private void createGridRow(Label label, TextField textField, Field field) {
final int gridShift = MODEL.getFields().size();
GRID.add(label, 0, gridShift);
GridPane.setHalignment(label, HPos.RIGHT);
GRID.add(textField, 1, gridShift);
//
final RowConstraints row = new RowConstraints();
row.setFillHeight(true);
row.setVgrow(Priority.NEVER);
GRID.getRowConstraints().add(row);
}
示例11: TimeRangeViewSkin
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public TimeRangeViewSkin(TimeRangeView control) {
super(control);
Label overviewLabel = new Label();
overviewLabel.textProperty()
.bind(Bindings
.createStringBinding(
() -> control.getUnitsToPrint() == 0 ? ""
: Messages
.getString("TimeRangeViewSkin.PERIOD_LABEL", control.getUnitsToPrint(),
Messages.getString(
control.getViewType().getPluralChronoMessageKey())),
control.unitsToPrintProperty(), control.viewTypeProperty()));
GridPane gridPane = new GridPane();
gridPane.getStyleClass().add("container");
gridPane.add(new Label(Messages.getString("TimeRangeViewSkin.START_LABEL")), 0, 0);
gridPane.add(control.getStartField(), 1, 0);
gridPane.add(new Label(Messages.getString("TimeRangeViewSkin.END_LABEL")), 0, 1);
gridPane.add(control.getEndField(), 1, 1);
gridPane.add(overviewLabel, 1, 2);
ColumnConstraints col1 = new ColumnConstraints();
ColumnConstraints col2 = new ColumnConstraints();
gridPane.getColumnConstraints().addAll(col1, col2);
GridPane.setHalignment(control.getStartField(), HPos.LEFT);
GridPane.setHalignment(control.getEndField(), HPos.LEFT);
GridPane.setFillWidth(control.getStartField(), true);
GridPane.setFillWidth(control.getEndField(), true);
getChildren().add(gridPane);
}
示例12: initUI
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private void initUI() {
VBox vbox = new VBox(20);
vbox.setStyle("-fx-padding: 10;");
Scene scene = new Scene(vbox, 400, 400);
stage.setScene(scene);
checkInDatePicker = new DatePicker();
checkOutDatePicker = new DatePicker();
checkInDatePicker.setValue(LocalDate.now());
final Callback<DatePicker, DateCell> dayCellFactory =
new Callback<DatePicker, DateCell>() {
@Override
public DateCell call(final DatePicker datePicker) {
return new DateCell() {
@Override
public void updateItem(LocalDate item, boolean empty) {
super.updateItem(item, empty);
if (item.isBefore(
checkInDatePicker.getValue().plusDays(1))
) {
setDisable(true);
setStyle("-fx-background-color: #ffc0cb;");
}
long p = ChronoUnit.DAYS.between(
checkInDatePicker.getValue(), item
);
setTooltip(new Tooltip(
"You're about to stay for " + p + " days")
);
}
};
}
};
checkOutDatePicker.setDayCellFactory(dayCellFactory);
checkOutDatePicker.setValue(checkInDatePicker.getValue().plusDays(1));
checkInDatePicker.setChronology(ThaiBuddhistChronology.INSTANCE);
checkOutDatePicker.setChronology(HijrahChronology.INSTANCE);
GridPane gridPane = new GridPane();
gridPane.setHgap(10);
gridPane.setVgap(10);
Label checkInlabel = new Label("Check-In Date:");
gridPane.add(checkInlabel, 0, 0);
GridPane.setHalignment(checkInlabel, HPos.LEFT);
gridPane.add(checkInDatePicker, 0, 1);
Label checkOutlabel = new Label("Check-Out Date:");
gridPane.add(checkOutlabel, 0, 2);
GridPane.setHalignment(checkOutlabel, HPos.LEFT);
gridPane.add(checkOutDatePicker, 0, 3);
vbox.getChildren().add(gridPane);
}
示例13: MovieCell
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
public MovieCell(MovieView movieView) {
this.movieView = movieView;
GridPane gridPane = new GridPane();
ColumnConstraints col1 = new ColumnConstraints();
ColumnConstraints col2 = new ColumnConstraints();
ColumnConstraints col3 = new ColumnConstraints();
ColumnConstraints col4 = new ColumnConstraints();
ColumnConstraints col5 = new ColumnConstraints();
col4.setHgrow(Priority.ALWAYS);
gridPane.getColumnConstraints().setAll(col1, col2, col3, col4, col5);
gridPane.setHgap(10);
// director image
directorImage = new ImageView();
directorImage.setFitWidth(60);
directorImage.setFitHeight(60);
directorImage.setEffect(new InnerShadow());
gridPane.add(directorImage, 0, 0);
GridPane.setRowSpan(directorImage, 2);
GridPane.setValignment(directorImage, VPos.TOP);
// title and year
titleLabel = new Label();
titleLabel.getStyleClass().add("title-label");
gridPane.add(titleLabel, 1, 0);
GridPane.setColumnSpan(titleLabel, 2);
GridPane.setValignment(titleLabel, VPos.TOP);
// director label
directorLabel = new Label();
directorLabel.getStyleClass().add("director-label");
gridPane.add(directorLabel, 1, 1);
GridPane.setValignment(directorLabel, VPos.TOP);
// genre label
genreLabel = new Label();
genreLabel.getStyleClass().add("genre-label");
gridPane.add(genreLabel, 4, 0);
// trailer label
trailerLabel = FontAwesomeIconFactory.get().createIconLabel(FontAwesomeIcon.FILM, "", "14px", "14px", ContentDisplay.GRAPHIC_ONLY);
trailerLabel.getStyleClass().add("trailer-label");
gridPane.add(trailerLabel, 3, 0);
GridPane.setHalignment(trailerLabel, HPos.LEFT);
GridPane.setValignment(trailerLabel, VPos.TOP);
trailerLabel.setOnMouseClicked(evt -> {
try {
Movie movie = getItem();
movieView.setSelectedTrailer(MovieApp.class.getResource("/trailers/" + movie.getTrailer()).toExternalForm());
} catch (NullPointerException e) {
movieView.setSelectedTrailer(MovieApp.class.getResource("/TrailerMissing.mp4").toExternalForm());
}
});
setGraphic(gridPane);
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
movieView.useClippingProperty().addListener(it -> updateClipping());
updateClipping();
}
示例14: 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;
}
示例15: nodeSelector
import javafx.scene.layout.GridPane; //導入方法依賴的package包/類
private void nodeSelector() {
weightGrid.getChildren().clear();
edgesGrid.getChildren().clear();
label.setText("Select adjacent vertices of '" + vertexValue[counter] + "' and input weight: ");
vertexGrid.getChildren().clear();
Label vertexLabel[] = new Label[steps];
Pane vPane[] = new Pane[steps];
edges = new JFXTextField[steps];
for (int i = 0; i < steps; i++) {
vertexLabel[i] = new Label();
vPane[i] = new Pane();
edges[i] = new JFXTextField();
vertexGrid.add(vPane[i], i, 0);
vertexLabel[i].setAlignment(Pos.CENTER);
vertexLabel[i].setText(vertexValue[i]);
//selector is initialized in initialize() and
//will help to select adjacent nodes
GridPane.setFillHeight(selectors[i], true);
GridPane.setFillWidth(selectors[i], true);
selectors[i].setText(vertexValue[i]);
selectors[i].setTextFill(Color.WHITE);
selectors[i].setStyle("-fx-background-color: " + colors[i]
+ "; -fx-border-color: #000000;"
+ " -fx-background-radius: 10 10 10 10;"
+ "; -fx-border-radius: 10 10 10 10;");
selectors[i].setPrefSize(100, 100);
edgesGrid.add(selectors[i], i, 0);
GridPane.setHalignment(vertexLabel[i], HPos.CENTER);
if (i == counter) {
selectors[i].setDisable(true);
vertexLabel[i].setTextFill(Color.WHITE);
vPane[i].setStyle("-fx-background-color: " + colors[i]
+ "; -fx-border-color: #000000;"
+ " -fx-background-radius: 10 10 10 10;"
+ "; -fx-border-radius: 10 10 10 10;");
} else {
vertexLabel[i].setTextFill(Color.BLACK);
vPane[i].setStyle("-fx-background-color: #B2DFDB; -fx-border-color: #000000;");
selectors[i].setDisable(false);
}
//This portion gonna add the edges fields
edges[i].setFocusColor(Color.web("1A237E"));
edges[i].setUnFocusColor(Color.web("#4d4d4d"));
edges[i].setText("∞");
if (i == counter) {
edges[i].setText("0");
}
edges[i].setAlignment(Pos.CENTER);
edges[i].setDisable(true);
weightGrid.add(edges[i], i, 0);
vertexGrid.add(vertexLabel[i], i, 0);
}
// counter++;
}