当前位置: 首页>>代码示例>>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;未经允许,请勿转载。