本文整理汇总了Java中javafx.scene.layout.ColumnConstraints.setPrefWidth方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnConstraints.setPrefWidth方法的具体用法?Java ColumnConstraints.setPrefWidth怎么用?Java ColumnConstraints.setPrefWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.layout.ColumnConstraints
的用法示例。
在下文中一共展示了ColumnConstraints.setPrefWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadGridData
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
public static void loadGridData(GridPane grid,Main main, DescriptionEntretien d){
// Grid initialisation ( reset )
grid.getColumnConstraints().clear();
// Grid Creation
// for each moment of the interview we add a collumn
for (int j = 0; j < d.getNumberCols(); j++) {
ColumnConstraints c = new ColumnConstraints();
c.setMinWidth(180);
c.setPrefWidth(Control.USE_COMPUTED_SIZE);
c.setMaxWidth(Control.USE_COMPUTED_SIZE);
grid.getColumnConstraints().add(c);
}
for (int i = 0; i < 1; i++) {
for (int j = 0; j < d.getNumberCols(); j++) {
// Creation of the Moment box
MomentExpVBox mp = new MomentExpVBox(main);
addMomentExpBorderPaneListener(mp, main);
MomentExperience mom;
boolean hasMoment = false;
if (main.getCurrentDescription() != null) {
for (MomentExperience m : d.getMoments()) {
if(m.getGridCol() == j){
mom = m;
mp.setMoment(mom);
hasMoment = true;
}
}
}
if (hasMoment) {
mp.showMoment();
mp.LoadMomentData();
loadTypes(mp, main);
loadSousMoment(mp,main);
}
grid.add(mp,j,i);
}
}
}
示例2: execute
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
@Override
public void execute() {
momentExpPane.showMoment();
main.getCurrentDescription().addMomentExp(momentExpPane.getMoment());
if(momentExpPane.getCol() == main.getCurrentDescription().getNumberCols()-1){
MomentExpVBox mb = new MomentExpVBox(main, true);
MainViewTransformations.addMomentExpBorderPaneListener(mb, main);
ColumnConstraints c = new ColumnConstraints();
c.setMinWidth(180);
c.setPrefWidth(Control.USE_COMPUTED_SIZE);
c.setMaxWidth(Control.USE_COMPUTED_SIZE);
// add a new col and the borderPane
main.getGrid().getColumnConstraints().add(c);
main.getGrid().add(mb,main.getCurrentDescription().getNumberCols(), 0);
// increase the number of col by one
main.getCurrentDescription().setNumberCols(main.getCurrentDescription().getNumberCols()+1);
}
main.needToSave();
}
示例3: createBody
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
/**
* Creates the node used for the body part of each cell.
*
* In this default implementation the body consists of a grid pane with
* three columns. The middle column is used for showing the title of
* calendar entries. This column will get whatever space is left after
* the icon and the time column have used what they need. This means
* that a very long title will automatically be truncated.
*
* @return the body node
*/
protected Node createBody() {
// icon column
ColumnConstraints iconColumn = new ColumnConstraints();
// title column
ColumnConstraints descriptionColumn = new ColumnConstraints();
descriptionColumn.setFillWidth(true);
descriptionColumn.setHgrow(Priority.SOMETIMES);
descriptionColumn.setMinWidth(0);
descriptionColumn.setPrefWidth(0);
// time column
ColumnConstraints timeColumn = new ColumnConstraints();
timeColumn.setHalignment(HPos.RIGHT);
gridPane = new GridPane();
gridPane.setGridLinesVisible(true);
gridPane.setMinWidth(0);
gridPane.setPrefWidth(0);
gridPane.getStyleClass().add(AGENDA_VIEW_BODY);
gridPane.getColumnConstraints().addAll(iconColumn, descriptionColumn, timeColumn);
return gridPane;
}
示例4: buildQueueSettingsPane
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
private Node buildQueueSettingsPane() {
final GridPane queueSettingsPane = new GridPane();
queueSettingsPane.add(new Label("Maximum number of active torrents (upload or download): "), 0, 0);
queueSettingsPane.add(activeTorrentsLimitField, 1, 0);
queueSettingsPane.add(new Label("Maximum number of active downloads: "), 0, 1);
queueSettingsPane.add(activeDownloadsLimitField, 1, 1);
queueSettingsPane.add(new Label("Maximum number of active uploads: "), 0, 2);
queueSettingsPane.add(activeUploadsLimitField, 1, 2);
final ColumnConstraints firstColumn = new ColumnConstraints();
firstColumn.setHgrow(Priority.ALWAYS);
final ColumnConstraints secondColumn = new ColumnConstraints();
secondColumn.setPrefWidth(60);
secondColumn.setMinWidth(60);
queueSettingsPane.getColumnConstraints().addAll(firstColumn, secondColumn);
queueSettingsPane.setVgap(5);
return queueSettingsPane;
}
示例5: updateVisibility
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
private void updateVisibility() {
for (int row = 0; row < 6; row++) {
RowConstraints rowConstraints = new RowConstraints();
rowConstraints.setFillHeight(true);
rowConstraints.setMinHeight(Region.USE_PREF_SIZE);
rowConstraints.setMaxHeight(Region.USE_COMPUTED_SIZE);
rowConstraints.setPrefHeight(Region.USE_COMPUTED_SIZE);
rowConstraints.setVgrow(Priority.ALWAYS);
gridPane.getRowConstraints().add(rowConstraints);
}
ColumnConstraints weekColumn = new ColumnConstraints();
weekColumn.setHalignment(HPos.RIGHT);
weekColumn.setMaxWidth(Region.USE_COMPUTED_SIZE);
weekColumn.setMinWidth(Region.USE_PREF_SIZE);
weekColumn.setPrefWidth(Region.USE_COMPUTED_SIZE);
weekColumn.setFillWidth(true);
weekColumn.setHgrow(Priority.NEVER);
gridPane.getColumnConstraints().add(weekColumn);
for (int col = 0; col < 7; col++) {
ColumnConstraints columnConstraints = new ColumnConstraints();
columnConstraints.setHalignment(HPos.CENTER);
columnConstraints.setMaxWidth(Region.USE_COMPUTED_SIZE);
columnConstraints.setMinWidth(Region.USE_PREF_SIZE);
columnConstraints.setPrefWidth(Region.USE_COMPUTED_SIZE);
columnConstraints.setFillWidth(true);
columnConstraints.setHgrow(Priority.ALWAYS);
gridPane.getColumnConstraints().add(columnConstraints);
}
}
示例6: YearViewSkin
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
public YearViewSkin(YearView view) {
super(view);
view.dateProperty().addListener(evt -> updateMonths());
GridPane gridPane = new GridPane();
gridPane.getStyleClass().add("container");
gridPane.setMaxSize(MAX_VALUE, MAX_VALUE);
for (int row = 0; row < 3; row++) {
RowConstraints rowConstraints = new RowConstraints();
rowConstraints.setMinHeight(Region.USE_PREF_SIZE);
rowConstraints.setPrefHeight(Region.USE_COMPUTED_SIZE);
rowConstraints.setMaxHeight(Region.USE_COMPUTED_SIZE);
rowConstraints.setVgrow(Priority.ALWAYS);
rowConstraints.setValignment(VPos.CENTER);
gridPane.getRowConstraints().add(rowConstraints);
}
for (int col = 0; col < 4; col++) {
ColumnConstraints colConstraints = new ColumnConstraints();
colConstraints.setMinWidth(Region.USE_PREF_SIZE);
colConstraints.setPrefWidth(Region.USE_COMPUTED_SIZE);
colConstraints.setMaxWidth(Region.USE_COMPUTED_SIZE);
colConstraints.setHgrow(Priority.ALWAYS);
colConstraints.setHalignment(HPos.CENTER);
gridPane.getColumnConstraints().add(colConstraints);
}
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 4; col++) {
Month month = Month.of(row * 4 + col + 1);
YearMonthView yearMonthView = view.getMonthView(month);
yearMonthView.setShowMonthArrows(false);
yearMonthView.setShowTodayButton(false);
yearMonthView.setShowUsageColors(true);
yearMonthView.setClickBehaviour(YearMonthView.ClickBehaviour.SHOW_DETAILS);
gridPane.add(yearMonthView, col, row);
// do not bind date, we manage it manually
view.bind(yearMonthView, false);
}
}
getChildren().add(gridPane);
updateMonths();
}
示例7: createContent
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
@Override
protected Node createContent() {
leftSide = createLeftHandSide();
rightSide = createRightHandSide();
leftColumn = new ColumnConstraints();
leftColumn.setPercentWidth(50);
leftColumn.setMinWidth(Region.USE_COMPUTED_SIZE);
leftColumn.setPrefWidth(Region.USE_COMPUTED_SIZE);
leftColumn.setMaxWidth(Double.MAX_VALUE);
leftColumn.setFillWidth(true);
rightColumn = new ColumnConstraints();
rightColumn.setPercentWidth(50);
rightColumn.setMinWidth(Region.USE_COMPUTED_SIZE);
rightColumn.setPrefWidth(Region.USE_COMPUTED_SIZE);
rightColumn.setMaxWidth(Double.MAX_VALUE);
rightColumn.setFillWidth(true);
RowConstraints rowConstraints = new RowConstraints();
rowConstraints.setPercentHeight(100);
rowConstraints.setFillHeight(true);
// no need to assign a style class, will be auto-assigned by superclass ("content")
gridPane = new GridPane();
gridPane.setHgap(20);
gridPane.getColumnConstraints().addAll(leftColumn, rightColumn);
gridPane.getRowConstraints().addAll(rowConstraints);
gridPane.add(leftSide, 0, 0);
gridPane.add(rightSide, 1, 0);
getSkinnable().widthProperty().addListener(it -> updateLayout());
return gridPane;
}
示例8: initializeEditorCanvas
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
private void initializeEditorCanvas() {
//reset canvas from eventual previous labyrinths
resetCanvas();
//make sure we know the current size
updateCanvasSize();
//calculate the TILE_SIZE appropriate for the window size and size of the Labyrinth
int smallerCanvasDimension = Integer.min(CANVAS_HEIGHT, CANVAS_WIDTH) - 2 * MARGIN;
int largerLabyrinthDimension = Integer.max(labyrinth.getHeight(), labyrinth.getWidth());
TILE_SIZE = smallerCanvasDimension / largerLabyrinthDimension;
//set size of the GridView
RowConstraints rowConstraints = new RowConstraints();
rowConstraints.setPrefHeight(TILE_SIZE);
rowConstraints.setMinHeight(TILE_SIZE);
rowConstraints.setMaxHeight(TILE_SIZE);
for (int rowIndex = 0; rowIndex < labyrinth.getHeight(); rowIndex++) {
canvasGridPane.addRow(rowIndex);
canvasGridPane.getRowConstraints().add(rowConstraints);
}
ColumnConstraints columnConstraints = new ColumnConstraints();
columnConstraints.setPrefWidth(TILE_SIZE);
columnConstraints.setMinWidth(TILE_SIZE);
columnConstraints.setMaxWidth(TILE_SIZE);
for (int colIndex = 0; colIndex < labyrinth.getWidth(); colIndex++) {
canvasGridPane.addRow(colIndex);
canvasGridPane.getColumnConstraints().add(columnConstraints);
}
}
示例9: drawColumn
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
public void drawColumn() {
// Remove any previous constraints
columnGridPane.getRowConstraints().clear();
columnGridPane.getColumnConstraints().clear();
// Set the column Constraints
ColumnConstraints col0 = new ColumnConstraints();
col0.setMinWidth(5);
col0.setPrefWidth(Control.USE_COMPUTED_SIZE);
col0.setMaxWidth(Control.USE_COMPUTED_SIZE);
col0.setFillWidth(true);
col0.setHgrow(Priority.ALWAYS);
this.columnGridPane.getColumnConstraints().add(col0);
// Add the Y-Axis
// this.yAxisCenterStackPane.getChildren().add(axisCenter);
// this.axisCenterAnchorPane.widthProperty().addListener( stageSizeListener );
// this.axisCenterAnchorPane.heightProperty().addListener( stageSizeListener );
// Now add the X-Axis
axisLeftStackPane.getChildren().add(axisLeft);
this.axisLeftAnchorPane.widthProperty().addListener( stageSizeListener );
this.axisLeftAnchorPane.heightProperty().addListener( stageSizeListener );
axisCenterStackPane.getChildren().add(axisCenter);
this.axisCenterAnchorPane.widthProperty().addListener( stageSizeListener );
this.axisCenterAnchorPane.heightProperty().addListener( stageSizeListener );
axisRightStackPane.getChildren().add(axisRight);
this.axisRightAnchorPane.widthProperty().addListener( stageSizeListener );
this.axisRightAnchorPane.heightProperty().addListener( stageSizeListener );
}
示例10: prepareRatioGrid
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
/**
* Note that JavaFx GridPane uses (col, row) instead of (row, col)
*/
private void prepareRatioGrid() {
squidSpeciesList = squidProject.getTask().getSquidSpeciesModelList();
indexOfBackgroundSpecies = -1;
ratiosGridPane.getRowConstraints().clear();
RowConstraints rowCon = new RowConstraints();
rowCon.setPrefHeight(BUTTON_HEIGHT);
ratiosGridPane.getRowConstraints().add(rowCon);
ratiosGridPane.getColumnConstraints().clear();
ColumnConstraints colcon = new ColumnConstraints(BUTTON_WIDTH);
colcon.setPrefWidth(BUTTON_WIDTH);
colcon.setHalignment(HPos.CENTER);
ratiosGridPane.getColumnConstraints().add(colcon);
for (int i = 0; i < squidSpeciesList.size(); i++) {
if (squidSpeciesList.get(i).getIsBackground()) {
indexOfBackgroundSpecies = squidSpeciesList.get(i).getMassStationIndex();
squidProject.getTask().setIndexOfBackgroundSpecies(indexOfBackgroundSpecies);
Text colText = new Text(squidSpeciesList.get(i).getIsotopeName());
colText.setFont(Font.font("Courier New", FontWeight.BOLD, 12));
ratiosGridPane.add(colText, 0, i + 1);
Text rowText = new Text(squidSpeciesList.get(i).getIsotopeName());
rowText.setFont(Font.font("Courier New", FontWeight.BOLD, 12));
ratiosGridPane.add(rowText, i + 1, 0);
} else {
Button colButton = new SquidRowColButton(i, -1, squidSpeciesList.get(i).getIsotopeName());
ratiosGridPane.add(colButton, 0, i + 1);
Button rowButton = new SquidRowColButton(-1, i, squidSpeciesList.get(i).getIsotopeName());
ratiosGridPane.add(rowButton, i + 1, 0);
}
Label corLabel = new Label("ROW /\n COL");
corLabel.setFont(Font.font("Courier New", FontWeight.BOLD, 2));
corLabel.setStyle(
" -fx-font-family: \"Courier New\", \"Lucida Sans\", \"Segoe UI\", Helvetica, Arial, sans-serif;\n"
+ " -fx-font-weight: bold;\n"
+ " -fx-font-size: 7pt;\n"
);
corLabel.setWrapText(true);
ratiosGridPane.add(corLabel, 0, 0);
ratiosGridPane.getRowConstraints().add(rowCon);
ratiosGridPane.getColumnConstraints().add(colcon);
}
populateRatioGrid();
// center in window
double width = primaryStageWindow.getScene().getWidth();
ratiosGridPane.setLayoutX((width - (squidSpeciesList.size() + 1) * BUTTON_WIDTH) / 2.0);
ratiosGridPane.setLayoutY(15);
}
示例11: Actions
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
public Actions() {
columnConstraints = new ColumnConstraints();
columnConstraints0 = new ColumnConstraints();
columnConstraints1 = new ColumnConstraints();
rowConstraints = new RowConstraints();
button = new Button();
button0 = new Button();
button1 = new Button();
setPrefHeight(32.0);
setPrefWidth(186.0);
setStyle("-fx-background-color: none;");
getStylesheets().add("/view/common/../../css/main.css");
columnConstraints.setHgrow(javafx.scene.layout.Priority.SOMETIMES);
columnConstraints.setMaxWidth(120.0);
columnConstraints.setMinWidth(10.0);
columnConstraints.setPrefWidth(95.0);
columnConstraints0.setHgrow(javafx.scene.layout.Priority.SOMETIMES);
columnConstraints0.setMaxWidth(150.0);
columnConstraints0.setMinWidth(10.0);
columnConstraints0.setPrefWidth(100.0);
columnConstraints1.setHgrow(javafx.scene.layout.Priority.SOMETIMES);
columnConstraints1.setMaxWidth(192.0);
columnConstraints1.setMinWidth(10.0);
columnConstraints1.setPrefWidth(110.0);
rowConstraints.setMinHeight(10.0);
rowConstraints.setPrefHeight(30.0);
rowConstraints.setVgrow(javafx.scene.layout.Priority.SOMETIMES);
button.setDefaultButton(true);
button.setMnemonicParsing(false);
button.setOnAction(this::handleEditButton);
button.setText("Edit");
GridPane.setColumnIndex(button0, 1);
button0.setMnemonicParsing(false);
button0.setOnAction(this::handleViewButton);
button0.getStyleClass().add("btn-primary");
button0.setText("View");
GridPane.setColumnIndex(button1, 2);
button1.setCancelButton(true);
button1.setMnemonicParsing(false);
button1.setOnAction(this::handleDeleteButton);
button1.setText("Delete");
getColumnConstraints().add(columnConstraints);
getColumnConstraints().add(columnConstraints0);
getColumnConstraints().add(columnConstraints1);
getRowConstraints().add(rowConstraints);
getChildren().add(button);
getChildren().add(button0);
getChildren().add(button1);
}
示例12: createChart
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
/**
*
*/
public void createChart() {
// Add the row constraint (we only have one row)
RowConstraints row = new RowConstraints();
row.setMinHeight(5);
row.setPrefHeight(Control.USE_COMPUTED_SIZE);
row.setMaxHeight(Control.USE_COMPUTED_SIZE);
row.setFillHeight(true);
row.setVgrow(Priority.ALWAYS);
this.chartGridPane.getRowConstraints().add(row);
for(int column_index=0; column_index<data[0].length; column_index++) {
FXMLLoader loader = new FXMLLoader(getClass().getResource("BarColumn.fxml"));
try {
VBox barColumn = (VBox) loader.load();
BarColumnController barColumnController = loader.getController();
barColumnController.setData(data);
barColumnController.setColumnIndex(column_index);
barColumnController.setAlphabet("dna");
barColumnController.setLabels(labels);
barColumnController.drawColumn();
this.chartGridPane.add(barColumn, column_index, 0);
// Set the column constraints
ColumnConstraints col = new ColumnConstraints();
col.setMinWidth(5);
col.setPrefWidth(Control.USE_COMPUTED_SIZE);
col.setMaxWidth(Control.USE_COMPUTED_SIZE);
col.setFillWidth(true);
col.setHgrow(Priority.ALWAYS);
this.chartGridPane.getColumnConstraints().add(col);
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例13: buildTransferSectionPane
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
private Node buildTransferSectionPane() {
final Label timeElapsedLabel = new Label("Time Elapsed:");
timeElapsedLabel.setPadding(LABEL_PADDING);
final Label remainingLabel = new Label("Remaining:");
remainingLabel.setPadding(LABEL_PADDING);
final Label wastedLabel = new Label("Wasted:");
wastedLabel.setPadding(LABEL_PADDING);
final Label downloadedLabel = new Label("Downloaded:");
downloadedLabel.setPadding(LABEL_PADDING);
final Label uploadedLabel = new Label("Uploaded:");
uploadedLabel.setPadding(LABEL_PADDING);
final Label seedsLabel = new Label("Seeds:");
seedsLabel.setPadding(LABEL_PADDING);
final Label downloadSpeedLabel = new Label("Download Speed:");
downloadSpeedLabel.setPadding(LABEL_PADDING);
final Label uploadSpeedLabel = new Label("Upload Speed:");
uploadSpeedLabel.setPadding(LABEL_PADDING);
final Label peersLabel = new Label("Peers:");
peersLabel.setPadding(LABEL_PADDING);
final Label downLimitLabel = new Label("Down Limit:");
downLimitLabel.setPadding(LABEL_PADDING);
final Label upLimitLabel = new Label("Up Limit:");
upLimitLabel.setPadding(LABEL_PADDING);
final Label shareRatioLabel = new Label("Share Ratio:");
shareRatioLabel.setPadding(LABEL_PADDING);
final Label statusLabel = new Label("Status:");
statusLabel.setPadding(LABEL_PADDING);
final GridPane transferSectionPane = new GridPane();
transferSectionPane.add(timeElapsedLabel, 0, 0);
transferSectionPane.add(timeElapsedValueLabel, 1, 0);
transferSectionPane.add(remainingLabel, 2, 0);
transferSectionPane.add(remainingValueLabel, 3, 0);
transferSectionPane.add(wastedLabel, 4, 0);
transferSectionPane.add(wastedValueLabel, 5, 0);
transferSectionPane.add(downloadedLabel, 0, 1);
transferSectionPane.add(downloadedValueLabel, 1, 1);
transferSectionPane.add(uploadedLabel, 2, 1);
transferSectionPane.add(uploadedValueLabel, 3, 1);
transferSectionPane.add(seedsLabel, 4, 1);
transferSectionPane.add(seedsValueLabel, 5, 1);
transferSectionPane.add(downloadSpeedLabel, 0, 2);
transferSectionPane.add(downloadSpeedValueLabel, 1, 2);
transferSectionPane.add(uploadSpeedLabel, 2, 2);
transferSectionPane.add(uploadSpeedValueLabel, 3, 2);
transferSectionPane.add(peersLabel, 4, 2);
transferSectionPane.add(peersValueLabel, 5, 2);
transferSectionPane.add(downLimitLabel, 0, 3);
transferSectionPane.add(downLimitValueLabel, 1, 3);
transferSectionPane.add(upLimitLabel, 2, 3);
transferSectionPane.add(upLimitValueLabel, 3, 3);
transferSectionPane.add(shareRatioLabel, 4, 3);
transferSectionPane.add(shareRatioValueLabel, 5, 3);
transferSectionPane.add(statusLabel, 0, 4);
transferSectionPane.add(statusValueLabel, 1, 4);
final ColumnConstraints labelColumnConstraints = new ColumnConstraints();
labelColumnConstraints.setPrefWidth(220);
labelColumnConstraints.setMinWidth(120);
final ColumnConstraints valueColumnConstraints = new ColumnConstraints();
valueColumnConstraints.setPrefWidth(300);
valueColumnConstraints.setMinWidth(120);
transferSectionPane.getColumnConstraints().addAll(labelColumnConstraints, valueColumnConstraints,
labelColumnConstraints, valueColumnConstraints, labelColumnConstraints, valueColumnConstraints);
transferSectionPane.setVgap(0);
return transferSectionPane;
}
示例14: buildGeneralSectionPane
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
private Node buildGeneralSectionPane() {
final Label saveAsLabel = new Label("Save As:");
saveAsLabel.setPadding(LABEL_PADDING);
final Label totalSizeLabel = new Label("Total Size:");
totalSizeLabel.setPadding(LABEL_PADDING);
final Label piecesLabel = new Label("Pieces:");
piecesLabel.setPadding(LABEL_PADDING);
final Label createdOnLabel = new Label("Created On:");
createdOnLabel.setPadding(LABEL_PADDING);
final Label createdByLabel = new Label("Created By:");
createdByLabel.setPadding(LABEL_PADDING);
final Label addedOnLabel = new Label("Added On:");
addedOnLabel.setPadding(LABEL_PADDING);
final Label completedOnLabel = new Label("Completed On:");
completedOnLabel.setPadding(LABEL_PADDING);
final Label hashLabel = new Label("Hash:");
hashLabel.setPadding(LABEL_PADDING);
final Label commentLabel = new Label("Comment:");
commentLabel.setPadding(LABEL_PADDING);
final GridPane generalSectionPane = new GridPane();
generalSectionPane.add(saveAsLabel, 0, 0);
generalSectionPane.add(saveAsValueLabel, 1, 0);
generalSectionPane.add(totalSizeLabel, 0, 1);
generalSectionPane.add(totalSizeValueLabel, 1, 1);
generalSectionPane.add(piecesLabel, 2, 1);
generalSectionPane.add(piecesValueLabel, 3, 1);
generalSectionPane.add(createdOnLabel, 0, 2);
generalSectionPane.add(createdOnValueLabel, 1, 2);
generalSectionPane.add(createdByLabel, 2, 2);
generalSectionPane.add(createdByValueLabel, 3, 2);
generalSectionPane.add(addedOnLabel, 0, 3);
generalSectionPane.add(addedOnValueLabel, 1, 3);
generalSectionPane.add(completedOnLabel, 2, 3);
generalSectionPane.add(completedOnValueLabel, 3, 3);
generalSectionPane.add(hashLabel, 0, 4);
generalSectionPane.add(hashValueLabel, 1, 4);
generalSectionPane.add(commentLabel, 0, 5);
generalSectionPane.add(commentValueLabel, 1, 5);
generalSectionPane.setVgap(0);
final ColumnConstraints labelColumnConstraints = new ColumnConstraints();
labelColumnConstraints.setPrefWidth(180);
final ColumnConstraints valueColumnConstraints = new ColumnConstraints();
valueColumnConstraints.setPrefWidth(400);
generalSectionPane.getColumnConstraints().addAll(labelColumnConstraints, valueColumnConstraints,
labelColumnConstraints, valueColumnConstraints);
return generalSectionPane;
}
示例15: updateStrings
import javafx.scene.layout.ColumnConstraints; //导入方法依赖的package包/类
private void updateStrings() {
ModManager.getPrimaryStage().setTitle(localizer.formatMessage("windowtitle", settings.getVersion()));
appName.setText(localizer.getMessage("appname").toUpperCase());
versionName.setText(settings.getVersion());
modListButton.setText(localizer.getMessage("navbartabs.mods"));
backupListButton.setText(localizer.getMessage("navbartabs.backups"));
settingsButton.setText(localizer.getMessage("navbartabs.settings"));
aboutButton.setText(localizer.getMessage("navbartabs.about"));
modListButton.setEllipsisString(localizer.getMessage("navbartabs.mods"));
backupListButton.setEllipsisString(localizer.getMessage("navbartabs.backups"));
settingsButton.setEllipsisString(localizer.getMessage("navbartabs.settings"));
aboutButton.setEllipsisString(localizer.getMessage("navbartabs.about"));
/*
* JavaFX's GridPane pushes around elements when the size of a column changes.
* When changing the styling of the text for highlighted buttons, this becomes
* a problem, as the whole layout shifts every click. To get around this, it's
* necessary to compute the pixel width of the text in each button, then
* constrain the columns to be the maximum size of the text-no more, no less.
* Accurate HGaps can then be applied and the elements will not move around.
*
* To compute the actual size of the text in the scene, it's necessary to
* create an invisible stage, add a Text node with the font and size
* equivalent to the stylesheet's, then get the node's layout width.
*/
ColumnConstraints col1 = new ColumnConstraints();
ColumnConstraints col2 = new ColumnConstraints();
ColumnConstraints col3 = new ColumnConstraints();
ColumnConstraints col4 = new ColumnConstraints();
Text test = new Text();
test.setFont(Font.loadFont(MainView.class.getClassLoader().getResourceAsStream("Lato-Medium.ttf"), 18));
test.setId("pagetab-selected");
VBox t = new VBox();
t.getChildren().add(test);
Stage s = new Stage();
s.setOpacity(0);
s.setScene(new Scene(t, 500, 500));
s.show();
test.setText(localizer.getMessage("navbartabs.mods"));
col1.setPrefWidth(test.getLayoutBounds().getWidth());
test.setText(localizer.getMessage("navbartabs.backups"));
col2.setPrefWidth(test.getLayoutBounds().getWidth());
test.setText(localizer.getMessage("navbartabs.settings"));
col3.setPrefWidth(test.getLayoutBounds().getWidth());
test.setText(localizer.getMessage("navbartabs.about"));
col4.setPrefWidth(test.getLayoutBounds().getWidth());
s.close();
pageTabs.getColumnConstraints().clear();
pageTabs.getColumnConstraints().addAll(col1, col2, col3, col4);
}