Java Code Examples for javafx.scene.control.Button#setGraphic()
The following examples show how to use
javafx.scene.control.Button#setGraphic() .
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: SignedView.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 6 votes |
public SignedView() { Label label = new Label("Gluon - AWS Mobile Hub"); Button upload = new Button("Upload File"); upload.setGraphic(new Icon(MaterialDesignIcon.CLOUD_UPLOAD)); upload.setOnAction(e -> AWSService.getInstance().uploadFile("/assets/localFile.txt")); Button download = new Button("Download File"); download.setGraphic(new Icon(MaterialDesignIcon.CLOUD_DOWNLOAD)); download.setOnAction(e -> AWSService.getInstance().downloadFile("/public/example-image.png")); VBox controls = new VBox(15.0, label, upload, download); controls.setAlignment(Pos.CENTER); setCenter(controls); }
Example 2
Source File: PlayerController.java From Simple-Media-Player with MIT License | 6 votes |
private void setIcon(Button button,String path,int size){ Image icon = new Image(path); ImageView imageView = new ImageView(icon); imageView.setFitWidth(size); imageView.setFitHeight((int)(size * icon.getHeight() / icon.getWidth())); button.setGraphic(imageView); //设置图标点击时发亮 ColorAdjust colorAdjust = new ColorAdjust(); button.setOnMousePressed(event -> { colorAdjust.setBrightness(0.5); button.setEffect(colorAdjust); }); button.setOnMouseReleased(event -> { colorAdjust.setBrightness(0); button.setEffect(colorAdjust); }); }
Example 3
Source File: PVList.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private Node createToolbar() { final Button refresh = new Button(); refresh.setGraphic(ImageCache.getImageView(PVList.class, "/icons/refresh.png")); refresh.setTooltip(new Tooltip(Messages.PVListRefreshTT)); refresh.setOnAction(event -> triggerRefresh()); return refresh; // If more buttons are added: // return new HBox(5, refresh); }
Example 4
Source File: DockCommandsBox.java From AnchorFX with GNU Lesser General Public License v3.0 | 5 votes |
private void createCloseButton() { Image closeImage = new Image("close.png"); closeButton = new Button() { @Override public void requestFocus() { } }; closeButton.setGraphic(new ImageView(closeImage)); closeButton.getStyleClass().add("docknode-command-button-close"); closeButton.setOnAction(e -> { if (node.getCloseRequestHandler() != null) { if (node.getCloseRequestHandler().canClose()) { node.undock(); } } else { node.undock(); } }); node.closeableProperty().addListener((observer, oldValue, newValue) -> changeCommandsState()); node.containerProperty().addListener((observer, oldValue, newValue) -> changeCommandsState()); node.floatingProperty().addListener((observer, oldValue, newValue) -> changeStateForFloatingState()); getChildren().add(closeButton); }
Example 5
Source File: About.java From SmartCity-ParkingManagement with Apache License 2.0 | 5 votes |
public void display(final Stage primaryStage, final WindowEnum __, final Button buttonMute) { window = primaryStage; window.setTitle("About"); window.setWidth(1350); window.setHeight(450); final Label label = new Label(TEXT); label.setAlignment(Pos.CENTER); label.setGraphic(new ImageView(new Image(IMAGE))); label.setStyle("-fx-background-color: white;\n" + "-fx-text-fill: black;\n" + "-fx-background-radius: 10px;\n" + "-fx-padding: 10px;\n" + "-fx-graphic-text-gap: 10px;\n" + "-fx-font-family: 'Arial';\n" + "-fx-font-size: 18px;"); final VBox vbox = new VBox(10); vbox.setStyle("-fx-background-color: null; -fx-padding: 10px;"); // System.out.println("HERE IS BUTTONMUTE: "+ buttonMute.toString()); if (!isLinuxOS) { final Button AboutMute = StaticMethods.cloneButton(buttonMute); muteButtonsAL.add(AboutMute); vbox.getChildren().add(AboutMute); } final Button backButton = new Button(); backButton.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("back_button.png")))); backButton.getStyleClass().add("button-go"); backButton.setOnAction(λ -> { window.close(); // if (!isLinuxOS) // StaticMethods.dealWithMute(mediaPlayer, buttonMute, true); prevWindows.get(prevWindows.size() - 1).window.show(); prevWindows.remove(prevWindows.size() - 1); }); vbox.getChildren().addAll(label, backButton); vbox.setAlignment(Pos.CENTER); final Scene scene = new Scene(vbox); window.setScene(scene); scene.getStylesheets().add(getClass().getResource("mainStyle.css").toExternalForm()); window.show(); }
Example 6
Source File: StringTable.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private Button createToolbarButton(final String id, final String tool_tip, final EventHandler<ActionEvent> handler) { final Button button = new Button(); try { // Icons are not centered inside the button until the // button is once pressed, or at least focused via "tab" button.setGraphic(ImageCache.getImageView(ImageCache.class, "/icons/" + id + ".png")); // Using the image as a background like this centers the image, // but replaces the complete characteristic button outline with just the icon. // button.setBackground(new Background(new BackgroundImage(new Image(Activator.getIcon(id)), // BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, // BackgroundPosition.CENTER, // new BackgroundSize(16, 16, false, false, false, false)))); button.setTooltip(new Tooltip(tool_tip)); } catch (Exception ex) { logger.log(Level.WARNING, "Cannot load icon for " + id, ex); button.setText(tool_tip); } // Without defining the button size, the buttons may start out zero-sized // until they're first pressed/tabbed button.setMinSize(35, 25); button.setOnAction(handler); // Forcing a layout of the button on later UI ticks // tends to center the image Platform.runLater(() -> Platform.runLater(button::requestLayout)); return button; }
Example 7
Source File: EditorDemo.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private Button createButton(final ActionDescription action) { final Button button = new Button(); try { button.setGraphic(ImageCache.getImageView(action.getIconResourcePath())); } catch (final Exception ex) { logger.log(Level.WARNING, "Cannot load action icon", ex); } button.setTooltip(new Tooltip(action.getToolTip())); button.setOnAction(event -> action.run(editor.getDisplayEditor())); return button; }
Example 8
Source File: ExecuteDisplayAction.java From phoebus with Eclipse Public License 1.0 | 5 votes |
public static Button asButton(final DisplayEditorInstance editor) { final Runnable action = new ExecuteDisplayAction(editor); final Button button = new Button(); button.setGraphic(new ImageView(icon)); button.setTooltip(new Tooltip(Messages.Run)); button.setOnAction(event -> action.run()); return button; }
Example 9
Source File: BigButtonDemo.java From mars-sim with GNU General Public License v3.0 | 5 votes |
@Override public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Alpha Base" + System.lineSeparator() + "Population : 8"); btn.setGraphic(new Rectangle(30,30, Color.RED)); btn.setMinHeight(200); btn.setMinWidth(250); //btn.setStyle("-fx-alignment: LEFT;"); btn.setAlignment(Pos.BASELINE_LEFT); StackPane root = new StackPane(); root.getChildren().add(btn); primaryStage.setScene(new Scene(root, 300, 250)); primaryStage.show(); }
Example 10
Source File: DraggableNode.java From exit_code_java with GNU General Public License v3.0 | 5 votes |
public void restoreSize(){ HBox titleBar=(HBox) getTop(); Button btnMax= (Button) titleBar.getChildren().get(3); btnMax.setGraphic(new ImageView(Apps.maximize_img)); setPrefWidth(nonMaxSizeWidth); setPrefHeight(nonMaxSizeHeight); setLayoutX(layoutXnoMax); setLayoutY(layoutYnoMax); onEdge=false; }
Example 11
Source File: DraggableNode.java From exit_code_java with GNU General Public License v3.0 | 5 votes |
private void snapOnEdge(double x, double y, double width, double height){ HBox titleBar=(HBox) getTop(); Button btnMax= (Button) titleBar.getChildren().get(3); btnMax.setGraphic(new ImageView(Apps.maximize_img)); setLayoutX(x); setLayoutY(y); setPrefWidth(width); setPrefHeight(height); onEdge=true; }
Example 12
Source File: TitledNodeSkin.java From graph-editor with Eclipse Public License 1.0 | 5 votes |
/** * Creates the content of the node skin - header, title, close button, etc. */ private void createContent() { header.getStyleClass().setAll(STYLE_CLASS_HEADER); header.setAlignment(Pos.CENTER); title.getStyleClass().setAll(STYLE_CLASS_TITLE); final Region filler = new Region(); HBox.setHgrow(filler, Priority.ALWAYS); final Button closeButton = new Button(); closeButton.getStyleClass().setAll(STYLE_CLASS_BUTTON); header.getChildren().addAll(title, filler, closeButton); contentRoot.getChildren().add(header); getRoot().getChildren().add(contentRoot); closeButton.setGraphic(AwesomeIcon.TIMES.node()); closeButton.setCursor(Cursor.DEFAULT); closeButton.setOnAction(event -> Commands.removeNode(getGraphEditor().getModel(), getNode())); contentRoot.minWidthProperty().bind(getRoot().widthProperty()); contentRoot.prefWidthProperty().bind(getRoot().widthProperty()); contentRoot.maxWidthProperty().bind(getRoot().widthProperty()); contentRoot.minHeightProperty().bind(getRoot().heightProperty()); contentRoot.prefHeightProperty().bind(getRoot().heightProperty()); contentRoot.maxHeightProperty().bind(getRoot().heightProperty()); contentRoot.setLayoutX(BORDER_WIDTH); contentRoot.setLayoutY(BORDER_WIDTH); contentRoot.getStyleClass().setAll(STYLE_CLASS_BACKGROUND); }
Example 13
Source File: ButtonPair.java From helloiot with GNU General Public License v3.0 | 5 votes |
@Override public Node constructContent() { goup = new Button(); goup.setGraphic(IconBuilder.create(IconFontGlyph.FA_SOLID_CHEVRON_UP, 22.0).styleClass("icon-fill").build()); goup.setContentDisplay(ContentDisplay.TOP); goup.getStyleClass().add("buttonbase"); goup.getStyleClass().add("buttonup"); VBox.setVgrow(goup, Priority.SOMETIMES); goup.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); goup.setFocusTraversable(false); goup.setOnAction(event -> { device.sendStatus(roll ? device.rollNextStatus() : device.nextStatus()); }); godown = new Button(); godown.setGraphic(IconBuilder.create(IconFontGlyph.FA_SOLID_CHEVRON_DOWN, 22.0).styleClass("icon-fill").build()); godown.setContentDisplay(ContentDisplay.TOP); godown.getStyleClass().add("buttonbase"); godown.getStyleClass().add("buttondown"); VBox.setVgrow(godown, Priority.SOMETIMES); godown.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); godown.setFocusTraversable(false); godown.setOnAction(event -> { device.sendStatus(roll ? device.rollPrevStatus() : device.prevStatus()); }); // setIconStatus(IconStatus.valueOf("TEXT/ON/OFF")); VBox content = new VBox(goup, godown); content.setSpacing(4); VBox.setVgrow(content, Priority.SOMETIMES); content.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); return content; }
Example 14
Source File: GetPassByMail.java From SmartCity-ParkingManagement with Apache License 2.0 | 4 votes |
public void display(final Stage primaryStage, final WindowEnum prevWindow) { window = primaryStage; window.setTitle("Get Password By Email"); // window.initModality(Modality.APPLICATION_MODAL); final GridPane grid = new GridPane(); grid.setPadding(new Insets(20, 20, 20, 20)); grid.setVgap(8); grid.setHgap(10); grid.setBackground( new Background(new BackgroundFill(Color.LIGHTBLUE, CornerRadii.EMPTY, new Insets(2, 2, 2, 2)))); window.setWidth(550); window.setHeight(180); final Label instruction = new Label("Please enter your eMail address in order to get your password"); GridPane.setConstraints(instruction, 0, 0); final TextField eMailInput = new TextField(); final String defaultMail = "[email protected]"; eMailInput.setText(defaultMail); GridPane.setConstraints(eMailInput, 0, 1); final Button sendButton = new Button(); sendButton.setText("Send Mail"); sendButton.setOnAction(e -> { if (eMailInput.getText().equals(defaultMail)) new AlertBox().display("Bad Input", "The mail you entered is the default! " + "\nPlease try again."); else if (!isValidMailAddress(eMailInput)) new AlertBox().display("Bad Input", "Illegal address entered! " + "\nPlease try again."); else { try { sendPassword(eMailInput); } catch (final Exception eMailException) { System.out.println(e); } window.close(); AbstractWindow.prevWindows.get(AbstractWindow.prevWindows.size() - 1).window.show(); AbstractWindow.prevWindows.remove(AbstractWindow.prevWindows.size() - 1); new AlertBox().display("Password Sent", "The password was sent to your eMail account"); } }); GridPane.setConstraints(sendButton, 0, 2); final Button backButton = new Button(); backButton.setGraphic(new ImageView(new Image(getClass().getResourceAsStream("back_button.png")))); backButton.getStyleClass().add("button-go"); backButton.setOnAction(λ -> { window.close(); handleBack(); }); GridPane.setConstraints(backButton, 1, 2); grid.getChildren().addAll(instruction, eMailInput, sendButton, backButton); final Scene scene = new Scene(grid, 420, 150); scene.getStylesheets().add(getClass().getResource("mainStyle.css").toExternalForm()); window.setScene(scene); window.show(); }
Example 15
Source File: BasicView.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 4 votes |
public BasicView() { items.setHgap(5.0); items.setVgap(10.0); items.setPadding(new Insets(10)); PlayerService.getInstance().getService().ifPresent(service -> { if (service.isReady()) { updateProductDetails(service); } else { service.readyProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { updateProductDetails(service); service.readyProperty().removeListener(this); } } }); } }); Label lblHealth = new Label("", MaterialDesignIcon.HEALING.graphic()); lblHealth.textProperty().bind(Bindings.concat("Current Health: ", player.healthProperty())); lblHealth.setFont(Font.font(24.0)); lblHealth.textFillProperty().bind(Bindings.when(player.healthProperty().lessThanOrEqualTo(0)).then(Color.RED).otherwise(Color.BLUE)); Button fight = new Button("Fight!"); fight.setGraphic(new Icon(MaterialDesignIcon.POWER)); fight.setOnAction(e -> player.dealDamage()); fight.disableProperty().bind(player.healthProperty().lessThanOrEqualTo(0)); getApplication().addLayerFactory(LAYER_INVENTORY, () -> { Label lblHealthPotions = new Label("", MaterialDesignIcon.HEALING.graphic()); lblHealthPotions.textProperty().bind(Bindings.concat("Health Potions: ", player.ownedHealthPotionsProperty())); Button btnHealthPotions = new Button("consume"); btnHealthPotions.disableProperty().bind(player.ownedHealthPotionsProperty().lessThanOrEqualTo(0).or(player.healthProperty().isEqualTo(Player.MAX_HEALTH))); btnHealthPotions.setOnAction(e -> player.consumeHealthPotion()); HBox.setHgrow(lblHealthPotions, Priority.ALWAYS); HBox healthPotions = new HBox(10.0, lblHealthPotions, btnHealthPotions); healthPotions.setAlignment(Pos.TOP_RIGHT); Label lblWoodenShield = new Label("Wooden Shield", MaterialDesignIcon.LOCAL_BAR.graphic()); lblWoodenShield.textFillProperty().bind(Bindings.when(player.woodenShieldOwnedProperty()).then(Color.BLUEVIOLET).otherwise(Color.LIGHTGRAY)); HBox woodenShield = new HBox(10.0, lblWoodenShield); woodenShield.setAlignment(Pos.CENTER_LEFT); VBox inventory = new VBox(15.0, healthPotions, woodenShield); inventory.setAlignment(Pos.CENTER_LEFT); return new SidePopupView(inventory, Side.RIGHT, true); }); setOnShowing(e -> { Button btnInventory = MaterialDesignIcon.SHOPPING_BASKET.button(e2 -> { getApplication().showLayer(LAYER_INVENTORY); }); getApplication().getAppBar().getActionItems().add(btnInventory); }); VBox controls = new VBox(15.0, lblHealth, fight); controls.setAlignment(Pos.TOP_CENTER); controls.setPadding(new Insets(15.0, 5.0, 0.0, 5.0)); setCenter(controls); setBottom(items); }
Example 16
Source File: AudioViewerEditor.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
@Override @FxThread protected void createContent(@NotNull final VBox root) { final Label durationLabel = new Label(Messages.AUDIO_VIEWER_EDITOR_DURATION_LABEL + ":"); final Label bitsPerSampleLabel = new Label(Messages.AUDIO_VIEWER_EDITOR_BITS_PER_SAMPLE_LABEL + ":"); final Label channelsLabel = new Label(Messages.AUDIO_VIEWER_EDITOR_CHANNELS_LABEL + ":"); final Label dataTypeLabel = new Label(Messages.AUDIO_VIEWER_EDITOR_DATA_TYPE_LABEL + ":"); final Label sampleRateLabel = new Label(Messages.AUDIO_VIEWER_EDITOR_SAMPLE_RATE_LABEL + ":"); durationField = new TextField(); durationField.setEditable(false); bitsPerSampleField = new TextField(); bitsPerSampleField.setEditable(false); channelsField = new TextField(); channelsField.setEditable(false); dataTypeField = new TextField(); dataTypeField.setEditable(false); sampleRateField = new TextField(); sampleRateField.setEditable(false); final GridPane gridPane = new GridPane(); gridPane.add(durationLabel, 0, 0); gridPane.add(bitsPerSampleLabel, 0, 1); gridPane.add(channelsLabel, 0, 2); gridPane.add(dataTypeLabel, 0, 3); gridPane.add(sampleRateLabel, 0, 4); gridPane.add(durationField, 1, 0); gridPane.add(bitsPerSampleField, 1, 1); gridPane.add(channelsField, 1, 2); gridPane.add(dataTypeField, 1, 3); gridPane.add(sampleRateField, 1, 4); playButton = new Button(); playButton.setGraphic(new ImageView(Icons.PLAY_128)); playButton.setOnAction(event -> processPlay()); stopButton = new Button(); stopButton.setGraphic(new ImageView(Icons.STOP_128)); stopButton.setOnAction(event -> processStop()); stopButton.setDisable(true); final HBox container = new HBox(); FXUtils.addToPane(gridPane, container); FXUtils.addToPane(playButton, container); FXUtils.addToPane(stopButton, container); FXUtils.addToPane(container, root); FXUtils.addClassTo(playButton, CssClasses.BUTTON_WITHOUT_RIGHT_BORDER); FXUtils.addClassTo(stopButton, CssClasses.BUTTON_WITHOUT_LEFT_BORDER); FXUtils.addClassTo(container, CssClasses.DEF_HBOX); FXUtils.addClassTo(gridPane, CssClasses.DEF_GRID_PANE); FXUtils.addClassesTo(root, CssClasses.DEF_VBOX, CssClasses.AUDIO_VIEW_EDITOR_CONTAINER); DynamicIconSupport.addSupport(playButton, stopButton); }
Example 17
Source File: LanguageChooserDialog.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
private void initComponents() { setTitle(chooser.getName()); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { //detach listeners from the chooser treeViewModel.setDelegate(null); listModel.setListFacade(null); chooser.getRemainingSelections().removeReferenceListener(LanguageChooserDialog.this); } }); Container pane = getContentPane(); pane.setLayout(new BorderLayout()); JSplitPane split = new JSplitPane(); JPanel leftPane = new JPanel(new BorderLayout()); //leftPane.add(new JLabel("Available Languages"), BorderLayout.NORTH); availTable.setAutoCreateRowSorter(true); availTable.setTreeViewModel(treeViewModel); availTable.getRowSorter().toggleSortOrder(0); availTable.addActionListener(new DoubleClickActionListener()); leftPane.add(new JScrollPane(availTable), BorderLayout.CENTER); Button addButton = new Button(LanguageBundle.getString("in_sumLangAddLanguage")); addButton.setOnAction(this::doAdd); addButton.setGraphic(new ImageView(Icons.Forward16.asJavaFX())); leftPane.add(GuiUtility.wrapParentAsJFXPanel(addButton), BorderLayout.PAGE_END); split.setLeftComponent(leftPane); JPanel rightPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; labelPane.add(new JLabel(LanguageBundle.getString("in_sumLangRemain")), //$NON-NLS-1$ new GridBagConstraints()); remainingLabel.setText(chooser.getRemainingSelections().get().toString()); labelPane.add(remainingLabel, gbc); labelPane.add(new JLabel(LanguageBundle.getString("in_sumSelectedLang")), gbc); //$NON-NLS-1$ rightPane.add(labelPane, BorderLayout.PAGE_START); list.setModel(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addActionListener(new DoubleClickActionListener()); rightPane.add(new JScrollPane(list), BorderLayout.CENTER); Button removeButton = new Button(LanguageBundle.getString("in_sumLangRemoveLanguage")); removeButton.setOnAction(this::doRemove); removeButton.setGraphic(new ImageView(Icons.Back16.asJavaFX())); rightPane.add(GuiUtility.wrapParentAsJFXPanel(removeButton), BorderLayout.PAGE_END); split.setRightComponent(rightPane); pane.add(split, BorderLayout.CENTER); ButtonBar buttonBar = new OKCloseButtonBar( this::doOK, this::doRollback ); pane.add(GuiUtility.wrapParentAsJFXPanel(buttonBar), BorderLayout.PAGE_END); }
Example 18
Source File: dashboardBase.java From Client with MIT License | 4 votes |
public void loadNodes() { //runs after config has been loaded //Load font Font.loadFont(getClass().getResource("Roboto.ttf").toExternalForm().replace("%20",""), 13); //apply stylesheet getStylesheets().add(getClass().getResource("style.css").toExternalForm()); //add style "pane" for every pane (dashboardBase itself is a pane with many panes) getStyleClass().add("pane"); //apply current theme setStyle("bg-color: "+config.get("bg-color")+";font-color: "+config.get("font-color")+";"); //init of base nodes //bottomButtonBar - will contain the Settings Button bottomButtonBar = new HBox(); bottomButtonBar.getStyleClass().add("pane"); bottomButtonBar.setAlignment(Pos.CENTER_RIGHT); settingsButton = new Button(); settingsButton.setGraphic(getIcon("gmi-settings")); settingsButton.setOnMouseClicked(event -> { if(currentPane == PANE.settings) { closeSettings(); currentPane = PANE.actions; } else switchPane(PANE.settings); }); bottomButtonBar.getChildren().add(settingsButton); //mainPane - will contain actionsPane, settingsPane and also goodbyePane mainPane = new StackPane(); mainPane.setPadding(new Insets(10,10,0,10)); mainPane.getStyleClass().add("pane"); //Init children of mainPane actionsPane = new StackPane(); // Where actions will be stored actionsPane.getStyleClass().add("pane"); //Adding stylesheet class to actionsPane settingsPane = getSettingsPane(); // Will contain Settings goodbyePane = getGoodbyePane(); // Will contain goodbye message loadingPane = getLoadingPane(); // Will contain loading spinner and a message //add children of mainPane to mainPane mainPane.getChildren().addAll(actionsPane, settingsPane, goodbyePane, loadingPane); //set all the children nodes opacity to 0 //actionsPane.setOpacity(0); //settingsPane.setOpacity(0); //goodbyePane.setOpacity(0); //loadingPane.setOpacity(0); //settingsPane.toFront(); //enable caching to improve performance (Especially on embedded and Mobile) actionsPane.setCache(true); actionsPane.setCacheHint(CacheHint.SPEED); settingsPane.setCache(true); settingsPane.setCacheHint(CacheHint.SPEED); loadingPane.setCache(true); loadingPane.setCacheHint(CacheHint.SPEED); goodbyePane.setCache(true); goodbyePane.setCacheHint(CacheHint.SPEED); settingsButton.setCache(true); settingsButton.setCacheHint(CacheHint.SPEED); setCache(true); setCacheHint(CacheHint.SPEED); //finally add base nodes to the base Scene setCenter(mainPane); setBottom(bottomButtonBar); }
Example 19
Source File: BasicView.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 3 votes |
public BasicView() { Label label = new Label("Hello JavaFX World!"); Button button = new Button("Change the World!"); button.setGraphic(new Icon(MaterialDesignIcon.LANGUAGE)); button.setOnAction(e -> label.setText("Hello JavaFX Universe!")); VBox controls = new VBox(15.0, label, button); controls.setAlignment(Pos.CENTER); setCenter(controls); }
Example 20
Source File: JFXHelper.java From Schillsaver with MIT License | 3 votes |
/** * Creates a button control with an icon on it. * * @param iconPath * The path to the icon. * * @param width * The width to resize the icon to. * * @param height * The height to resize the icon to. * * @throws NullPointerException * If the iconPath is null. * * @throws IllegalArgumentException * If the iconPath is empty. */ public static Button createIconButton(final @NonNull String iconPath, final int width, final int height) { if (iconPath.isEmpty()) { throw new IllegalArgumentException("The icon path cannot be empty."); } final Button button = new Button(); final Image image = new Image(iconPath, (double) width, (double) height, true, true); button.setGraphic(new ImageView(image)); return button; }