Java Code Examples for javafx.scene.layout.HBox#setBackground()
The following examples show how to use
javafx.scene.layout.HBox#setBackground() .
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: CustomGaugeSkinDemo.java From medusademo with Apache License 2.0 | 7 votes |
@Override public void start(Stage stage) { HBox pane = new HBox(gauge0, gauge1, gauge2, gauge3, gauge4, gauge5, gauge6, gauge7, gauge8, gauge9); pane.setBackground(new Background(new BackgroundFill(Gauge.DARK_COLOR, CornerRadii.EMPTY, Insets.EMPTY))); pane.setPadding(new Insets(10)); pane.setPrefWidth(400); Scene scene = new Scene(pane); stage.setTitle("Medusa Custom Gauge Skin"); stage.setScene(scene); stage.show(); timer.start(); // Calculate number of nodes calcNoOfNodes(pane); System.out.println(noOfNodes + " Nodes in SceneGraph"); }
Example 2
Source File: ChargeSkin.java From Medusa with Apache License 2.0 | 6 votes |
private void initGraphics() { // Set initial size if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 || Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) { if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) { gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight()); } else { gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } } for (int i = 0 ; i < 12 ; i++) { Region bar = new Region(); bar.setPrefSize(20, 20 + (i * 4)); bars[i] = bar; } pane = new HBox(bars); pane.setSpacing(PREFERRED_WIDTH * 0.01960784); pane.setAlignment(Pos.BOTTOM_CENTER); pane.setFillHeight(false); pane.setBackground(new Background(new BackgroundFill(backgroundPaint, new CornerRadii(1024), Insets.EMPTY))); pane.setBorder(new Border(new BorderStroke(borderPaint, BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(borderWidth)))); getChildren().setAll(pane); }
Example 3
Source File: TilesfxClock.java From mars-sim with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("restriction") @Override public void start(Stage stage) { HBox pane = new HBox(20, days, hours, minutes, seconds); pane.setPadding(new Insets(10)); pane.setBackground(new Background(new BackgroundFill(Color.web("#606060"), CornerRadii.EMPTY, Insets.EMPTY))); //Scene scene = new Scene(pane); PerspectiveCamera camera = new PerspectiveCamera(); camera.setFieldOfView(7); Scene scene = new Scene(pane); scene.setCamera(camera); stage.setTitle("Countdown"); stage.setScene(scene); stage.show(); timer.start(); }
Example 4
Source File: Demo.java From Enzo with Apache License 2.0 | 6 votes |
@Override public void start(Stage stage) { HBox lcd = new HBox(); lcd.setPadding(new Insets(15, 15, 15, 15)); lcd.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))); lcd.setSpacing(10); lcd.setAlignment(Pos.CENTER); lcd.setFillHeight(false); HBox.setMargin(seg3, new Insets(0, 20, 0, 0)); lcd.getChildren().addAll(seg0, seg1, seg2, seg3, seg4, seg5); /* for (int i = 0 ; i < 256 ; i++) { System.out.println(i + " : " + Character.toString((char) i)); } */ StackPane pane = new StackPane(); pane.getChildren().setAll(lcd); Scene scene = new Scene(pane, Color.BLACK); stage.setTitle("Sixteen Segment DemoGauge"); stage.setScene(scene); stage.show(); timer.start(); }
Example 5
Source File: Demo.java From Enzo with Apache License 2.0 | 6 votes |
@Override public void start(Stage stage) { HBox lcd = new HBox(); lcd.setPadding(new Insets(15, 15, 15, 15)); lcd.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))); lcd.setSpacing(10); lcd.setAlignment(Pos.CENTER); lcd.setFillHeight(false); HBox.setMargin(seg3, new Insets(0, 20, 0, 0)); lcd.getChildren().addAll(seg0, seg1, seg2, seg3); /* for (int i = 0 ; i < 256 ; i++) { System.out.println(i + " : " + Character.toString((char) i)); } */ StackPane pane = new StackPane(); pane.getChildren().setAll(lcd); Scene scene = new Scene(pane, Color.BLACK); stage.setTitle("SevenSegment DemoGauge"); stage.setScene(scene); stage.show(); timer.start(); }
Example 6
Source File: ClientDisplay.java From Open-Lowcode with Eclipse Public License 2.0 | 5 votes |
/** * generates the JAVAFX component for the status bar * * @return the Pane */ public Pane generateStatusBar() { Label statusbar = new Label(""); statusbar.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getButton().equals(MouseButton.SECONDARY)) { final ClipboardContent content = new ClipboardContent(); content.putString(statusbar.getText()); Clipboard.getSystemClipboard().setContent(content); } else { Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Status Message"); alert.setHeaderText("Status Message"); alert.setContentText(statusbar.getText()); alert.showAndWait(); } } }); this.statuslabel = statusbar; HBox statusbarpane = new HBox(5); statusbarpane.setBackground(new Background(new BackgroundFill(Color.WHITE, null, null))); statusbarpane.getChildren().add(statusbar); return statusbarpane; }
Example 7
Source File: ParetoInfoPopup.java From charts with Apache License 2.0 | 5 votes |
private void initGraphics() { regularFont = Fonts.latoRegular(10); lightFont = Fonts.latoLight(10); itemText = new Text("NAME"); itemText.setFill(_textColor); itemText.setFont(regularFont); itemNameText = new Text("-"); itemNameText.setFill(_textColor); itemNameText.setFont(regularFont); line = new Line(0, 0, 0, 56); line.setStroke(_textColor); vBoxTitles = new VBox(2, itemText); vBoxTitles.setAlignment(Pos.CENTER_LEFT); VBox.setMargin(itemText, new Insets(3, 0, 0, 0)); vBoxValues = new VBox(2, itemNameText); vBoxValues.setAlignment(Pos.CENTER_RIGHT); VBox.setMargin(itemNameText, new Insets(3, 0, 0, 0)); HBox.setHgrow(vBoxValues, Priority.ALWAYS); hBox = new HBox(5, vBoxTitles, line, vBoxValues); hBox.setPrefSize(120, 69); hBox.setPadding(new Insets(5)); hBox.setBackground(new Background(new BackgroundFill(_backgroundColor, new CornerRadii(3), Insets.EMPTY))); hBox.setMouseTransparent(true); getContent().addAll(hBox); }
Example 8
Source File: Main.java From regulators with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { HBox pane = new HBox(regulator, feedbackRegulator, colorRegulator); pane.setSpacing(20); pane.setPadding(new Insets(10)); pane.setBackground(new Background(new BackgroundFill(Color.rgb(66,71,79), CornerRadii.EMPTY, Insets.EMPTY))); Scene scene = new Scene(pane); stage.setScene(scene); stage.show(); timer.start(); }
Example 9
Source File: InfoPopup.java From charts with Apache License 2.0 | 4 votes |
private void initGraphics() { Font regularFont = Fonts.latoRegular(10); Font lightFont = Fonts.latoLight(10); seriesText = new Text("SERIES"); seriesText.setFill(_textColor); seriesText.setFont(regularFont); seriesNameText = new Text("-"); seriesNameText.setFill(_textColor); seriesNameText.setFont(lightFont); seriesSumText = new Text("SUM"); seriesSumText.setFill(_textColor); seriesSumText.setFont(regularFont); seriesValueText = new Text("-"); seriesValueText.setFill(_textColor); seriesValueText.setFont(lightFont); itemText = new Text("ITEM"); itemText.setFill(_textColor); itemText.setFont(regularFont); itemNameText = new Text("-"); itemNameText.setFill(_textColor); itemNameText.setFont(lightFont); valueText = new Text("VALUE"); valueText.setFill(_textColor); valueText.setFont(regularFont); itemValueText = new Text("-"); itemValueText.setFill(_textColor); itemValueText.setFont(lightFont); line = new Line(0, 0, 0, 56); line.setStroke(_textColor); VBox vBoxTitles = new VBox(2, seriesText, seriesSumText, itemText, valueText); vBoxTitles.setAlignment(Pos.CENTER_LEFT); VBox.setMargin(itemText, new Insets(3, 0, 0, 0)); VBox vBoxValues = new VBox(2, seriesNameText, seriesValueText, itemNameText, itemValueText); vBoxValues.setAlignment(Pos.CENTER_RIGHT); VBox.setMargin(itemNameText, new Insets(3, 0, 0, 0)); HBox.setHgrow(vBoxValues, Priority.ALWAYS); hBox = new HBox(5, vBoxTitles, line, vBoxValues); hBox.setPrefSize(120, 69); hBox.setPadding(new Insets(5)); hBox.setBackground(new Background(new BackgroundFill(_backgroundColor, new CornerRadii(3), Insets.EMPTY))); hBox.setMouseTransparent(true); getContent().addAll(hBox); }
Example 10
Source File: JFXDecorator.java From JFoenix with Apache License 2.0 | 4 votes |
private void initializeContainers(Node node, boolean fullScreen, boolean max, boolean min) { buttonsContainer = new HBox(); buttonsContainer.getStyleClass().add("jfx-decorator-buttons-container"); buttonsContainer.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))); // BINDING buttonsContainer.setPadding(new Insets(4)); buttonsContainer.setAlignment(Pos.CENTER_RIGHT); // customize decorator buttons List<JFXButton> btns = new ArrayList<>(); if (fullScreen) { btns.add(btnFull); } if (min) { btns.add(btnMin); } if (max) { btns.add(btnMax); // maximize/restore the window on header double click buttonsContainer.addEventHandler(MouseEvent.MOUSE_CLICKED, (mouseEvent) -> { if (mouseEvent.getClickCount() == 2) { btnMax.fire(); } }); } btns.add(btnClose); text = new Text(); text.getStyleClass().addAll("jfx-decorator-text", "title", "jfx-decorator-title"); text.setFill(Color.WHITE); text.textProperty().bind(title); //binds the Text's text to title title.bind(primaryStage.titleProperty()); //binds title to the primaryStage's title graphicContainer = new HBox(); graphicContainer.setPickOnBounds(false); graphicContainer.setAlignment(Pos.CENTER_LEFT); graphicContainer.getChildren().setAll(text); HBox graphicTextContainer = new HBox(graphicContainer, text); graphicTextContainer.getStyleClass().add("jfx-decorator-title-container"); graphicTextContainer.setAlignment(Pos.CENTER_LEFT); graphicTextContainer.setPickOnBounds(false); HBox.setHgrow(graphicTextContainer, Priority.ALWAYS); HBox.setMargin(graphicContainer, new Insets(0, 8, 0, 8)); buttonsContainer.getChildren().setAll(graphicTextContainer); buttonsContainer.getChildren().addAll(btns); buttonsContainer.addEventHandler(MouseEvent.MOUSE_ENTERED, (enter) -> allowMove = true); buttonsContainer.addEventHandler(MouseEvent.MOUSE_EXITED, (enter) -> { if (!isDragging) { allowMove = false; } }); buttonsContainer.setMinWidth(180); contentPlaceHolder.getStyleClass().add("jfx-decorator-content-container"); contentPlaceHolder.setMinSize(0, 0); StackPane clippedContainer = new StackPane(node); contentPlaceHolder.getChildren().add(clippedContainer); ((Region) node).setMinSize(0, 0); VBox.setVgrow(contentPlaceHolder, Priority.ALWAYS); contentPlaceHolder.getStyleClass().add("resize-border"); contentPlaceHolder.setBorder(new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(0, 4, 4, 4)))); // BINDING Rectangle clip = new Rectangle(); clip.widthProperty().bind(clippedContainer.widthProperty()); clip.heightProperty().bind(clippedContainer.heightProperty()); clippedContainer.setClip(clip); this.getChildren().addAll(buttonsContainer, contentPlaceHolder); }