本文整理匯總了Java中javafx.scene.layout.StackPane.setPrefSize方法的典型用法代碼示例。如果您正苦於以下問題:Java StackPane.setPrefSize方法的具體用法?Java StackPane.setPrefSize怎麽用?Java StackPane.setPrefSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.layout.StackPane
的用法示例。
在下文中一共展示了StackPane.setPrefSize方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createEmojiNode
import javafx.scene.layout.StackPane; //導入方法依賴的package包/類
/**
* 創建emoji圖片節點
*
* @param emoji
* emoji
* @param size
* 圖片顯示大小
* @param pad
* 圖片間距
* @param isCursor
* 是否需要圖片光標及鼠標處理事件
* @return
*/
public static Node createEmojiNode(Emoji emoji, int size, int pad) {
// 將表情放到stackpane中
StackPane stackPane = new StackPane();
stackPane.setMaxSize(size, size);
stackPane.setPrefSize(size, size);
stackPane.setMinSize(size, size);
stackPane.setPadding(new Insets(pad));
ImageView imageView = new ImageView();
imageView.setFitWidth(size);
imageView.setFitHeight(size);
imageView.setImage(ImageCache.getInstance().getImage(getEmojiImagePath(emoji.getHex())));
stackPane.getChildren().add(imageView);
return stackPane;
}
示例2: createIconContent
import javafx.scene.layout.StackPane; //導入方法依賴的package包/類
public static Node createIconContent() {
StackPane sp = new StackPane();
Rectangle rectangle = new Rectangle(62, 62, Color.LIGHTGREY);
rectangle.setStroke(Color.BLACK);
sp.setPrefSize(rectangle.getWidth(), rectangle.getHeight());
Rectangle biggerRec = new Rectangle(55, 55, Color.web("#1c89f4"));
Rectangle smallerRec = new Rectangle(35, 35, Color.web("#349b00"));
sp.getChildren().addAll(rectangle, biggerRec, smallerRec);
return new Group(sp);
}
示例3: setSymbolSize
import javafx.scene.layout.StackPane; //導入方法依賴的package包/類
public void setSymbolSize(final Series<X, Y> SERIES, final double SIZE) {
if (!getData().contains(SERIES)) { return; }
if (SERIES.getData().isEmpty()) { return; }
double symbolSize = Helper.clamp(0, 30, SIZE);
for (XYChart.Data<X, Y> data : SERIES.getData()) {
StackPane stackPane = (StackPane) data.getNode();
if (null == stackPane) { continue; }
stackPane.setPrefSize(symbolSize, symbolSize);
}
}
示例4: showPopup
import javafx.scene.layout.StackPane; //導入方法依賴的package包/類
protected void showPopup() {
init();
isShowing = true;
VBox popupLayout = new VBox();
popupLayout.setSpacing(10);
popupLayout.setPadding(new Insets(10, 10, 10, 10));
StackPane popupContent = new StackPane();
popupContent.setPrefSize(width, height);
popupContent.getStyleClass().add("notification");
popupContent.getChildren().addAll(popupLayout);
popup = new Popup();
popup.setX(getX());
popup.setY(getY());
popup.getContent().add(popupContent);
popup.addEventHandler(MouseEvent.MOUSE_PRESSED, new WeakEventHandler<>(event -> {
fireNotificationEvent(new NotificationEvent(this, popup, NotificationEvent.NOTIFICATION_PRESSED));
hidePopUp();
}));
popups.add(popup);
// Add a timeline for popup fade out
KeyValue fadeOutBegin = new KeyValue(popup.opacityProperty(), 1.0);
KeyValue fadeOutEnd = new KeyValue(popup.opacityProperty(), 0.0);
KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
KeyFrame kfEnd = new KeyFrame(popupAnimationTime, fadeOutEnd);
timeline = new Timeline(kfBegin, kfEnd);
timeline.setDelay(popupLifetime);
timeline.setOnFinished(actionEvent -> Platform.runLater(() -> {
hidePopUp();
}));
if (stage.isShowing()) {
stage.toFront();
} else {
stage.show();
}
popup.show(stage);
fireNotificationEvent(new NotificationEvent(this, popup, NotificationEvent.SHOW_NOTIFICATION));
timeline.play();
}
示例5: configureBox
import javafx.scene.layout.StackPane; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void configureBox(HBox root) {
StackPane container = new StackPane();
//container.setPrefHeight(700);
container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight());
container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;");
table= new TableView<AttClass>();
Label lview= new Label();
lview.setText("View Records");
lview.setId("lview");
bottomPane= new VBox();
tclock= new Text();
tclock.setId("lview");
//tclock.setFont(Font.font("Calibri", 20));
final Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
tclock.setText(DateFormat.getDateTimeInstance().format(new Date()));
}
}));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
bottomPane.getChildren().addAll(tclock,lview);
bottomPane.setAlignment(Pos.CENTER);
//table pane
namecol= new TableColumn<>("First Name");
namecol.setMinWidth(170);
namecol.setCellValueFactory(new PropertyValueFactory<>("name"));
admcol= new TableColumn<>("Identication No.");
admcol.setMinWidth(180);
admcol.setCellValueFactory(new PropertyValueFactory<>("adm"));
typecol= new TableColumn<>("Type");
typecol.setMinWidth(130);
typecol.setCellValueFactory(new PropertyValueFactory<>("type"));
timecol= new TableColumn<>("Signin");
timecol.setMinWidth(140);
timecol.setCellValueFactory(new PropertyValueFactory<>("timein"));
datecol= new TableColumn<>("Date");
datecol.setMinWidth(180);
datecol.setCellValueFactory(new PropertyValueFactory<>("date"));
table.getColumns().addAll(namecol, admcol, typecol, timecol, datecol);
table.setItems(getAtt());
att= getAtt();
table.setItems(FXCollections.observableArrayList(att));
table.setMinHeight(500);
btnrefresh = new Button("Refresh");
btnrefresh.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
table.setItems(getAtt());
}
});
laytable= new VBox(10);
laytable.getChildren().addAll(table, btnrefresh);
laytable.setAlignment(Pos.TOP_LEFT);
container.getChildren().addAll(bottomPane,laytable);
setAnimation();
sc.setContent(container);
root.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672)");
root.getChildren().addAll(getActionPane(),sc);
//service.start();
}
示例6: configureBox
import javafx.scene.layout.StackPane; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void configureBox(HBox root) {
StackPane container = new StackPane();
//container.setPrefHeight(700);
container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight());
container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;");
table= new TableView<OfficeClass>();
Label lview= new Label();
lview.setText("View Records");
lview.setId("lview");
bottomPane= new VBox();
tclock= new Text();
tclock.setId("lview");
//tclock.setFont(Font.font("Calibri", 20));
final Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
tclock.setText(DateFormat.getDateTimeInstance().format(new Date()));
}
}));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
bottomPane.getChildren().addAll(tclock, lview);
bottomPane.setAlignment(Pos.CENTER);
nocol= new TableColumn<>("no");
nocol.setMinWidth(130);
nocol.setCellValueFactory(new PropertyValueFactory<>("no"));
namecol= new TableColumn<>("First Name");
namecol.setMinWidth(170);
namecol.setCellValueFactory(new PropertyValueFactory<>("name"));
admcol= new TableColumn<>("Admission Number");
admcol.setMinWidth(180);
admcol.setCellValueFactory(new PropertyValueFactory<>("adm"));
timecol= new TableColumn<>("Signin");
timecol.setMinWidth(140);
timecol.setCellValueFactory(new PropertyValueFactory<>("timein"));
datecol= new TableColumn<>("Date");
datecol.setMinWidth(180);
datecol.setCellValueFactory(new PropertyValueFactory<>("date"));
table.getColumns().addAll(nocol,namecol, admcol, timecol, datecol);
table.setItems(getAtt());
att= getAtt();
table.setItems(FXCollections.observableArrayList(att));
table.setMinHeight(500);
btnrefresh = new Button("Refresh");
btnrefresh.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
table.setItems(getAtt());
}
});
laytable= new VBox(10);
laytable.getChildren().addAll(table, btnrefresh);
laytable.setAlignment(Pos.TOP_LEFT);
container.getChildren().addAll(bottomPane,laytable);
setAnimation();
sc.setContent(container);
root.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672)");
root.getChildren().addAll(getActionPane(),sc);
//service.start();
}
示例7: SlidesViewer
import javafx.scene.layout.StackPane; //導入方法依賴的package包/類
public SlidesViewer() {
pagination = new Pagination();
pagination.setOnMouseClicked(evt -> nextSlide());
pagination.setOnSwipeLeft(evt -> previousSlide());
pagination.setOnSwipeRight(evt -> nextSlide());
pagination.setOnScrollStarted(evt -> {
if (evt.getTotalDeltaX() > 0) {
nextSlide();
} else {
previousSlide();
}
});
pagination.setOnKeyTyped(evt -> {
switch (evt.getCode()) {
case LEFT:
previousSlide();
break;
case RIGHT:
case SPACE:
nextSlide();
break;
}
});
stackPane = new StackPane();
titleImageView = new ImageView(SlidesViewer.class.getResource("/title.png").toExternalForm());
titleImageView.fitWidthProperty().bind(stackPane.widthProperty());
titleImageView.fitHeightProperty().bind(stackPane.heightProperty());
titleImageView.setPreserveRatio(true);
stackPane.getChildren().addAll(pagination, titleImageView);
stackPane.getStyleClass().add("container");
stackPane.setPrefSize(0, 0);
Scene scene = new Scene(stackPane);
scene.getStylesheets().add(SlidesViewer.class.getResource("/slides-viewer.css").toExternalForm());
stage = new Stage();
stage.setScene(scene);
stage.setWidth(960);
stage.setHeight(540);
slidesEntry.addListener(it -> updateViewer());
}
示例8: mkRoot
import javafx.scene.layout.StackPane; //導入方法依賴的package包/類
@Override
public Node mkRoot() {
GesturePane pane = new GesturePane();
WebView webview = new WebView();
WebEngine engine = webview.getEngine();
pane.addEventHandler(AffineEvent.CHANGED, e -> {
String script = String.format(
"document.getElementsByTagName('body')[0].style.transform = " +
"'matrix(%s,0,0,%s,%s,%s)';",
e.namedCurrent().scaleX(),
e.namedCurrent().scaleY(),
e.namedCurrent().translateX(),
e.namedCurrent().translateY());
engine.executeScript(script);
});
TextField bar = new TextField(INTERESTING_CSS);
bar.setOnAction(e -> engine.load(bar.getText()));
engine.load(bar.getText());
engine.documentProperty().addListener((o, p, n) -> {
if (n == null) return;
pane.zoomTo(1, Point2D.ZERO);
pane.setTarget(new Transformable() {
@Override
public double width() {
return Double.valueOf(engine.executeScript("document.body.scrollWidth")
.toString());
}
@Override
public double height() {
return Double.valueOf(engine.executeScript("document.body.scrollHeight")
.toString());
}
});
});
Label description = new Label("GesturePane supports Transformable implementation. This " +
"sample shows a WebView behind an empty GesturePane " +
"listening for AffineEvents. The Affine matrix is " +
"translated to CSS matrix and applied the the body " +
"element. \nBe aware that all mouse events will be " +
"consumed by the pane so you cannot click any " +
"links.");
description.setWrapText(true);
description.setPadding(new Insets(16));
StackPane glass = new StackPane(webview, pane);
glass.setPrefSize(0, 0);
VBox.setVgrow(glass, Priority.ALWAYS);
return new VBox(description, bar, glass);
}