Java Code Examples for javafx.scene.layout.StackPane#setPadding()

The following examples show how to use javafx.scene.layout.StackPane#setPadding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DemoLcd.java    From Enzo with Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane();
    pane.setPadding(new Insets(10, 10, 10, 10));
    pane.getChildren().setAll(control);

    Scene scene = new Scene(pane, Color.TRANSPARENT);

    stage.setTitle("Lcd demo");
    stage.centerOnScreen();
    //stage.initStyle(StageStyle.UNDECORATED);
    stage.setScene(scene);
    stage.show();        
            
    timer.start();

    calcNoOfNodes(scene.getRoot());
    System.out.println(noOfNodes + " Nodes in SceneGraph");
}
 
Example 2
Source File: PersonalPane.java    From oim-fx with MIT License 6 votes vote down vote up
private void initComponent() {
	headImageView.setClip(headImageClip);
	StackPane headStackPane = new StackPane();
	headStackPane.setPadding(new Insets(16, 10, 16, 16));
	headStackPane.getChildren().add(headImageView);

	nameLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1);-fx-font-size: 18px;");
	HBox nameHBox = new HBox();
	nameHBox.setAlignment(Pos.CENTER_LEFT);
	nameHBox.getChildren().add(nameLabel);

	menuButton.getStyleClass().remove("button");
	menuButton.getStyleClass().add("personal-menu-button");
	menuButton.setGraphic(new ImageView());
	
	StackPane buttonStackPane = new StackPane();
	buttonStackPane.setPadding(new Insets(0, 20, 0, 0));
	buttonStackPane.getChildren().add(menuButton);

	this.setLeft(headStackPane);
	this.setCenter(nameHBox);
	this.setRight(buttonStackPane);
	this.setPrefWidth(180);
}
 
Example 3
Source File: Test.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(yearBox);
    //HBox pane = new HBox(20, tile1, tile2);
    pane.setPadding(new Insets(10));

    Scene scene = new Scene(pane);

    stage.setTitle("Test");
    stage.setScene(scene);
    stage.show();

    // Calculate number of nodes
    calcNoOfNodes(pane);
    System.out.println(noOfNodes + " Nodes in SceneGraph");

    //timer.start();
}
 
Example 4
Source File: MultiGaugeDemo.java    From medusademo with Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(gauge);
    pane.setPadding(new Insets(20));
    pane.setBackground(new Background(new BackgroundFill(Gauge.DARK_COLOR, CornerRadii.EMPTY, Insets.EMPTY)));

    Scene scene = new Scene(pane);

    stage.setTitle("Medusa MultiGauge");
    stage.setScene(scene);
    stage.show();

    timer.start();

    // Calculate number of nodes
    calcNoOfNodes(pane);
    System.out.println(noOfNodes + " Nodes in SceneGraph");
}
 
Example 5
Source File: Demo.java    From Enzo with Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) {
    ImageView imgView = new ImageView(backgroundImage);

    PushButton button1 = PushButtonBuilder.create()
                                          .status(PushButton.Status.DESELECTED)
                                          .color(Color.CYAN)
                                          .prefWidth(128)
                                          .prefHeight(128)
                                          .build();

    button1.setOnSelect(selectionEvent -> System.out.println("Select") );
    button1.setOnDeselect(selectionEvent -> System.out.println("Deselect") );

    StackPane pane = new StackPane();
    pane.setPadding(new Insets(10, 10, 10, 10));
    pane.getChildren().setAll(imgView, button1);

    Scene scene = new Scene(pane, 256, 256, Color.rgb(153, 153, 153));

    stage.setTitle("JavaFX PushButton");
    stage.setScene(scene);
    stage.show();
}
 
Example 6
Source File: DemoGauge.java    From Enzo with Apache License 2.0 6 votes vote down vote up
@Override public void start(Stage stage) throws Exception {
    StackPane pane = new StackPane();
    pane.setPadding(new Insets(5, 5, 5, 5));
    pane.getChildren().add(control);

    final Scene scene = new Scene(pane, Color.BLACK);
    scene.getStylesheets().add(getClass().getResource("demo.css").toExternalForm());
    //scene.setFullScreen(true);

    stage.setTitle("Gauge");
    stage.setScene(scene);
    stage.show();

    //timer.start();

    calcNoOfNodes(scene.getRoot());
    System.out.println(noOfNodes + " Nodes in SceneGraph");
}
 
Example 7
Source File: TextValidatorSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public TextValidatorSample() {
    String validatorCss = TextValidatorSample.class.getResource("Validators.css").toExternalForm();
    
    TextField dateField = new TextField();
    dateField.setPromptText("Enter a Large Number");
    dateField.setMaxHeight(TextField.USE_PREF_SIZE);

    TextInputValidatorPane<TextField> pane = new TextInputValidatorPane<TextField>();
    pane.setContent(dateField);
    pane.setValidator(new Validator<TextField>() {
        public ValidationResult validate(TextField control) {
            try {
                String text = control.getText();
                if (text == null || text.trim().equals("")) return null;
                double d = Double.parseDouble(text);
                if (d < 1000) {
                    return new ValidationResult("Should be > 1000", ValidationResult.Type.WARNING);
                }
                return null; // succeeded
            } catch (Exception e) {
                // failed
                return new ValidationResult("Bad number", ValidationResult.Type.ERROR);
            }
        }
    });

    StackPane rootSP = new StackPane();
    rootSP.setPadding(new Insets(12));
    rootSP.getChildren().add(pane);
    pane.getStylesheets().add(validatorCss);
    getChildren().add(rootSP);
}
 
Example 8
Source File: SankeyPlotTest.java    From charts with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(sankeyPlot);
    pane.setPadding(new Insets(10));

    Scene scene = new Scene(pane);

    stage.setTitle("Sankey Plot");
    stage.setScene(scene);
    stage.show();
}
 
Example 9
Source File: MatrixPlotTest.java    From charts with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(pixelMatrix);
    pane.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
    pane.setPadding(new Insets(10));

    Scene scene = new Scene(pane);

    stage.setTitle("MatrixPlot");
    stage.setScene(scene);
    stage.show();

    timer.start();
}
 
Example 10
Source File: Demo.java    From Enzo with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) throws Exception {
    StackPane pane = new StackPane();
    pane.setPadding(new Insets(5, 5, 5, 5));
    pane.getChildren().addAll(chart);

    Scene scene = new Scene(pane);
    //scene.setFullScreen(true);

    stage.setTitle("Demo SimpleLineChart");
    stage.setScene(scene);
    stage.show();

    calcNoOfNodes(scene.getRoot());
    System.out.println(noOfNodes + " Nodes in SceneGraph");
}
 
Example 11
Source File: PlayfairTest.java    From charts with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(playfairChart);
    pane.setPadding(new Insets(10));

    Scene scene = new Scene(new StackPane(pane));

    stage.setTitle("Playfair Chart Test");
    stage.setScene(scene);
    stage.show();

    //timer.start();
}
 
Example 12
Source File: ParallelCoordinatesChartTest.java    From charts with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(chart);
    pane.setPadding(new Insets(10));

    Scene scene = new Scene(pane);

    stage.setTitle("Parallel Coordinates Chart");
    stage.setScene(scene);
    stage.show();
}
 
Example 13
Source File: ViewChart.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Node constructContent() {
    areachart = new ChartNode();
    StackPane chart = areachart.getNode();
    chart.setMinSize(40.0, 240.0);
    chart.setPrefSize(40.0, 240.0);
    chart.setPadding(Insets.EMPTY);
    
    legendcontainer = new VBox();
    legendcontainer.getStyleClass().add("unitchartlegend");
    
    chartcontainer = new BorderPane(chart);
    return chartcontainer;
}
 
Example 14
Source File: Demo.java    From Enzo with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane();
    pane.setPadding(new Insets(10, 10, 10, 10));
    pane.getChildren().setAll(control);

    Scene scene = new Scene(pane, 200, 200);

    stage.setTitle("JavaFX TButton");
    stage.setScene(scene);
    stage.show();
}
 
Example 15
Source File: ViewNumberProgress.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void construct(IoTApp app) {
    super.construct(app);    
    
    if (glyph != null) {
        glyphnode = new StackPane(IconBuilder.create(glyph, 36.0).styleClass("unitinputicon").build());
        glyphnode.setPadding(new Insets(0, 0, 0, 6));
        boxview.getChildren().add(0, glyphnode);
    } 
    
    device.subscribeStatus(messageHandler);
}
 
Example 16
Source File: MultipleListPane.java    From oim-fx with MIT License 5 votes vote down vote up
private void initComponent() {

		StackPane logoStackPane = new StackPane();
		logoStackPane.setPadding(new Insets(20, 0, 0, 0));
		logoStackPane.getChildren().add(logoImageView);

		HBox lineHBox = new HBox();
		lineHBox.setMinHeight(1);
		lineHBox.setStyle("-fx-background-color:#ed3a3a;");

		textLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1);-fx-font-size: 16px;");

		HBox textLabelHBox = new HBox();
		textLabelHBox.setAlignment(Pos.CENTER);
		textLabelHBox.getChildren().add(textLabel);

		loginButton.setText("登录微信");
		loginButton.setPrefSize(220, 35);

		HBox loginButtonHBox = new HBox();
		loginButtonHBox.setPadding(new Insets(0, 4, 10, 4));
		loginButtonHBox.setAlignment(Pos.CENTER);
		loginButtonHBox.getChildren().add(loginButton);

		VBox vBox = new VBox();
		vBox.setSpacing(20);
		vBox.setStyle("-fx-background-color:#26292e;");
		vBox.getChildren().add(logoStackPane);
		vBox.getChildren().add(lineHBox);
		vBox.getChildren().add(textLabelHBox);
		vBox.getChildren().add(loginButtonHBox);

		this.setTop(vBox);
		this.setCenter(listRooPane);
		this.setStyle("-fx-background-color:#2e3238;");
	}
 
Example 17
Source File: MainScene.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public StackPane createChatBox() {
	chatBox = new ChatBox(this);
	chatBox.getAutoFillTextBox().getTextbox().requestFocus();
	chatBoxPane = new StackPane(chatBox);
	chatBoxPane.setMinHeight(chatBoxHeight);
	chatBoxPane.setPrefHeight(chatBoxHeight);
	chatBoxPane.setMaxHeight(chatBoxHeight);
	chatBoxPane.setPadding(new Insets(0, 0, 0, 0));
	return chatBoxPane;
}
 
Example 18
Source File: CircularPlotTest.java    From charts with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    StackPane pane = new StackPane(circluarPlot);
    pane.setPadding(new Insets(10));

    Scene scene = new Scene(pane);

    stage.setTitle("Circular Plot");
    stage.setScene(scene);
    stage.show();
}
 
Example 19
Source File: Exercise_16_17.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a stack pane for text
	StackPane paneForText = new StackPane(text);
	paneForText.setPadding(new Insets(20, 10, 5, 10));

	// Set slider properties
	slRed.setMin(0.0);
	slRed.setMax(1.0);
	slGreen.setMin(0.0);
	slGreen.setMax(1.0);
	slBlue.setMin(0.0);
	slBlue.setMax(1.0);
	slOpacity.setMin(0.0);
	slOpacity.setMax(1.0);

	// Create listeners
	slRed.valueProperty().addListener(ov -> setColor());
	slGreen.valueProperty().addListener(ov -> setColor());
	slBlue.valueProperty().addListener(ov -> setColor());
	slOpacity.valueProperty().addListener(ov -> setColor());
	slOpacity.setValue(1);


	// Create a grid pane for labeled sliders
	GridPane paneForSliders = new GridPane();
	paneForSliders.setAlignment(Pos.CENTER);
	paneForSliders.setVgap(5);
	paneForSliders.setHgap(5);
	paneForSliders.add(new Label("Red"), 0, 0);
	paneForSliders.add(slRed, 1, 0);
	paneForSliders.add(new Label("Green"), 0, 1);
	paneForSliders.add(slGreen, 1, 1);
	paneForSliders.add(new Label("Blue"), 0, 2);
	paneForSliders.add(slBlue, 1, 2);
	paneForSliders.add(new Label("Opacity"), 0, 3);
	paneForSliders.add(slOpacity, 1, 3);

	// Place nodes in a border pane
	BorderPane pane = new BorderPane();
	pane.setTop(paneForText);
	pane.setCenter(paneForSliders);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 250, 150);
	primaryStage.setTitle("Exercise_16_17"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 20
Source File: LastItem.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {

		StackPane headStackPane = new StackPane();
		headStackPane.setPadding(new Insets(10, 8, 12, 15));
		headStackPane.getChildren().add(imagePane);

		redLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1);");

		StackPane redStackPane = new StackPane();
		redStackPane.getChildren().add(redImageView);
		redStackPane.getChildren().add(redLabel);

		HBox redHBox = new HBox();
		redHBox.setAlignment(Pos.TOP_RIGHT);
		redHBox.getChildren().add(redStackPane);
		redHBox.setPadding(new Insets(5, 5, 0, 0));
		
		VBox redVBox = new VBox();
		redVBox.setAlignment(Pos.TOP_RIGHT);
		redVBox.getChildren().add(redHBox);

		StackPane leftStackPane = new StackPane();

		leftStackPane.getChildren().add(headStackPane);
		leftStackPane.getChildren().add(redVBox);

		//nameLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1);-fx-font-size: 14px;");

		HBox nameHBox = new HBox();
		nameHBox.getChildren().add(nameLabel);

		timeLabel.setStyle("-fx-text-fill:#666a77;");

		BorderPane nameBorderPane = new BorderPane();

		nameBorderPane.setCenter(nameHBox);
		nameBorderPane.setRight(timeLabel);

		//textLabel.setStyle("-fx-text-fill:rgba(152, 152, 152, 1);");

		HBox textHBox = new HBox();
		textHBox.setAlignment(Pos.CENTER_LEFT);
		textHBox.getChildren().add(textLabel);

		VBox centerVBox = new VBox();
		centerVBox.setSpacing(5);
		centerVBox.setPadding(new Insets(10, 10, 0, 0));
		centerVBox.getChildren().add(nameBorderPane);
		centerVBox.getChildren().add(textHBox);

		borderPane.setLeft(leftStackPane);
		borderPane.setCenter(centerVBox);
		this.getChildren().add(borderPane);
	}