當前位置: 首頁>>代碼示例>>Java>>正文


Java StackPane.setPrefSize方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Laity000,項目名稱:ChatRoom-JavaFX,代碼行數:29,代碼來源:EmojiDisplayer.java

示例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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:14,代碼來源:StackPaneSample.java

示例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);
    }
}
 
開發者ID:HanSolo,項目名稱:smoothcharts,代碼行數:11,代碼來源:SmoothedChart.java

示例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();
}
 
開發者ID:Team-Sprout,項目名稱:Clipcon-Client,代碼行數:48,代碼來源:ClipboardNotification.java

示例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();
}
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:74,代碼來源:AllAttendance.java

示例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();
	 }
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:75,代碼來源:Office_Entry.java

示例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());
}
 
開發者ID:hendrikebbers,項目名稱:ExtremeGuiMakeover,代碼行數:50,代碼來源:SlidesViewer.java

示例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);

}
 
開發者ID:tom91136,項目名稱:GestureFX,代碼行數:53,代碼來源:WebViewSample.java


注:本文中的javafx.scene.layout.StackPane.setPrefSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。