本文整理汇总了Java中javafx.scene.layout.GridPane类的典型用法代码示例。如果您正苦于以下问题:Java GridPane类的具体用法?Java GridPane怎么用?Java GridPane使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GridPane类属于javafx.scene.layout包,在下文中一共展示了GridPane类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import javafx.scene.layout.GridPane; //导入依赖的package包/类
public void start(Stage primaryStage) {
canvas = new GridPane();
canvas.setPrefSize(800,800);
canvas.setGridLinesVisible(true);
final int numCols = 9 ;
final int numRows = 8 ;
for (int i = 0; i < numCols; i++) {
ColumnConstraints colConst = new ColumnConstraints();
colConst.setPercentWidth(100.0 / numCols);
canvas.getColumnConstraints().add(colConst);
}
for (int i = 0; i < numRows; i++) {
RowConstraints rowConst = new RowConstraints();
rowConst.setPercentHeight(100.0 / numRows);
canvas.getRowConstraints().add(rowConst);
}
scene = new Scene(canvas, 800, 800);
primaryStage.setScene(scene);
bubble = new Bubble(scene);
primaryStage.show();
scene.setFill(createGridPattern());
}
示例2: WeekFieldsViewSkin
import javafx.scene.layout.GridPane; //导入依赖的package包/类
public WeekFieldsViewSkin(final WeekFieldsView view) {
super(view);
dayOfWeekComboBox = new ComboBox<>();
dayOfWeekComboBox.getItems().addAll(DayOfWeek.values());
dayOfWeekComboBox.setValue(view.getFirstDayOfWeek());
minimalDaysInFirstWeekComboBox = new ComboBox<>();
minimalDaysInFirstWeekComboBox.getItems().addAll(1, 2, 3, 4, 5, 6, 7);
minimalDaysInFirstWeekComboBox.setValue(view.getMinimalDaysInFirstWeek());
GridPane pane = new GridPane();
pane.getStyleClass().add("content");
pane.add(new Label("First day:"), 0, 0);
pane.add(new Label("Minimum days:"), 0, 1);
pane.add(dayOfWeekComboBox, 1, 0);
pane.add(minimalDaysInFirstWeekComboBox, 1, 1);
getChildren().add(pane);
// listeners
InvalidationListener updateListener = it -> updateValues();
dayOfWeekComboBox.valueProperty().addListener(updateListener);
minimalDaysInFirstWeekComboBox.valueProperty().addListener(updateListener);
view.weekFieldsProperty().addListener(it -> {
WeekFields fields = view.getWeekFields();
dayOfWeekComboBox.setValue(fields.getFirstDayOfWeek());
minimalDaysInFirstWeekComboBox.setValue(fields.getMinimalDaysInFirstWeek());
});
}
示例3: setupDispoGrid
import javafx.scene.layout.GridPane; //导入依赖的package包/类
private void setupDispoGrid() {
dispoRegion = new Region[32][32];
for (int y = 0; y < 32; y++) {
dispoGrid.getColumnConstraints().get(y).setFillWidth(true);
dispoGrid.getRowConstraints().get(y).setFillHeight(true);
for (int x = 0; x < 32; x++) {
Region region = new Region();
region.setMinSize(5.0, 5.0);
region.setId("dispoGrid");
region.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
dispoRegion[x][y] = region;
dispoGrid.getChildren().add(region);
GridPane.setConstraints(region, x, y);
int yCoord = y;
int xCoord = x;
region.setOnMouseClicked(event -> moveBlock(xCoord, yCoord));
}
}
}
示例4: 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);
}
示例5: 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();
}
示例6: EventLogger
import javafx.scene.layout.GridPane; //导入依赖的package包/类
public EventLogger() {
setVisible(false);
setPrefHeight(30);
setPrefWidth(612);
ColumnConstraints column1 = new ColumnConstraints();
column1.setPercentWidth(85);
column1.setHgrow(Priority.SOMETIMES);
ColumnConstraints column2 = new ColumnConstraints();
column2.setPercentWidth(15);
column2.setHgrow(Priority.SOMETIMES);
getColumnConstraints().clear();
getColumnConstraints().addAll(column1, column2);
RowConstraints row = new RowConstraints(10, 40, 40);
row.setVgrow(Priority.SOMETIMES);
getRowConstraints().clear();
getRowConstraints().add(row);
eventLabel = buildEventLabel();
setConstraints(eventLabel, 0, 0);
GridPane.setMargin(eventLabel, new Insets(0, 10, 0, 10));
serverLabel = new Label();
setConstraints(serverLabel, 1, 0);
GridPane.setMargin(serverLabel, new Insets(0, 10, 0, 10));
getChildren().addAll(eventLabel, serverLabel);
}
示例7: createLevelView
import javafx.scene.layout.GridPane; //导入依赖的package包/类
/**
* Creates the level view using an authoring renderer to
* keep track of the sprites on screen
*
* @return
*/
private Node createLevelView () {
Pane pane = new Pane();
Pane levelPane = new Pane();
myGrid = new GridPane();
myButton = placeableButton();
disableGrid();
myLevel.setBackgroundImageSize(Double.parseDouble(myBundle.getString("Width")),
Double.parseDouble(myBundle.getString("Height")));
myRenderer = new AuthoringRenderer(myLevel, levelPane, myGrid, myScale);
myRenderer.render();
levelPane.setOnMouseClicked(e -> handleMouseClick(e));
pane.getChildren().addAll(levelPane, myGrid, myButton);
return pane;
}
示例8: populateMonthPane
import javafx.scene.layout.GridPane; //导入依赖的package包/类
/**
* Creates and positions every node onto the GridPane for the given month and year.
* Uses 7 (weekdays) columns and (max.) 6 rows (weeks). The rows and columns are created on fly or
* are reused.
*
* @param monthPane The GradPane that is used for populating the DayNodes.
* @param month The month that should be displayed.
* @param year The year that should be displayed.
*/
private void populateMonthPane(GridPane monthPane, Month month, int year) {
monthPane.getChildren().clear();
int currentRow = 0;
for(LocalDate d = LocalDate.of(year, month, 1);
d.getMonthValue() == month.getValue();
d = d.plusDays(1)) {
Node dayNode = renderDayItem(d);
final LocalDate currentDate = d;
dayNode.setOnMouseClicked(event -> selectedDateProperty.set(currentDate));
int column = d.getDayOfWeek().getValue();
monthPane.add(dayNode, column, currentRow);
if(column == 7) {
currentRow++;
}
}
}
示例9: createExpandableContent
import javafx.scene.layout.GridPane; //导入依赖的package包/类
private static GridPane createExpandableContent(String content) {
Label label = new Label("Exception stacktrace");
TextArea textArea = new TextArea(content);
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;
}
示例10: start
import javafx.scene.layout.GridPane; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
GridPane pane = new GridPane();
pane.setAlignment(Pos.CENTER);
pane.setMaxSize(800, 600);
pane.setPrefSize(800, 600);
pane.setManaged(true);
pane.setVgap(3);
pane.setHgap(3);
pane.addRow(1, new Label("Chess Master"));
ComboBox<RenderWrapper> renderCombo = new ComboBox<>();
renderCombo.getItems().addAll(new RenderWrapper(new BGFXRenderer()), new RenderWrapper(new OpenGLRenderer()));
ChessMaster.getPluginManager().getExtensions(Renderer.class).stream().map(RenderWrapper::new).forEach(renderCombo.getItems()::add);
pane.addRow(2, new Label("Select a renderer:"), renderCombo);
Button button = new Button("Start!");
button.setOnAction(event -> {
ChessMaster.getLogger().info("Using renderer: {} ({})", renderCombo.getSelectionModel().getSelectedItem().renderer.getName(), renderCombo.getSelectionModel().getSelectedItem().renderer.getClass().getName());
renderCombo.getSelectionModel().getSelectedItem().renderer.render();
primaryStage.close();
});
pane.addRow(3, button);
primaryStage.setScene(new Scene(pane));
primaryStage.show();
}
示例11: loadGridData
import javafx.scene.layout.GridPane; //导入依赖的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);
}
}
}
示例12: start
import javafx.scene.layout.GridPane; //导入依赖的package包/类
@Override public void start(Stage stage) {
GridPane pane = new GridPane();
pane.setBackground(new Background(new BackgroundFill(Color.DARKGRAY, CornerRadii.EMPTY, Insets.EMPTY)));
pane.setPadding(new Insets(10));
pane.setHgap(10);
pane.setVgap(10);
pane.add(lineChartNotSmoothed, 0, 0);
pane.add(lineChartSmoothed, 1, 0);
pane.add(areaChartNotSmoothed, 0, 1);
pane.add(areaChartSmoothed, 1, 1);
pane.add(tweakedChart, 0, 2);
pane.add(tweaked2Chart, 1, 2);
Scene scene = new Scene(pane);
stage.setTitle("Smooth Charts");
stage.setScene(scene);
stage.show();
}
示例13: 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;
}
示例14: 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);
}
示例15: createRoot
import javafx.scene.layout.GridPane; //导入依赖的package包/类
@Override
@FXThread
protected @NotNull GridPane createRoot() {
final GridPane gridPane = new GridPane();
FXUtils.addClassesTo(gridPane, CSSClasses.DEF_GRID_PANE, CSSClasses.IMAGE_CHANNEL_PREVIEW);
return gridPane;
}