Java Code Examples for javafx.scene.control.Button#setId()
The following examples show how to use
javafx.scene.control.Button#setId() .
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: CustomNavigationDrawerSkin.java From WorkbenchFX with Apache License 2.0 | 6 votes |
/** * Initializes all parts of the skin. */ private void initializeParts() { drawerBox = new VBox(); drawerBox.getStyleClass().add("drawer-box"); header = new BorderPane(); header.getStyleClass().add("header"); menuContainer = new VBox(); menuContainer.getStyleClass().add("menu-container"); scrollPane = new PrettyScrollPane(menuContainer); backIconShape = new StackPane(); backIconShape.getStyleClass().add("shape"); backBtn = new Button("", backIconShape); backBtn.getStyleClass().add("icon"); backBtn.setId("back-button"); companyLogo = new Label(); companyLogo.getStyleClass().add("logo"); }
Example 2
Source File: NavigationDrawerSkin.java From WorkbenchFX with Apache License 2.0 | 6 votes |
/** * Initializes all parts of the skin. */ private void initializeParts() { drawerBox = new VBox(); drawerBox.getStyleClass().add("drawer-box"); header = new BorderPane(); header.getStyleClass().add("header"); menuContainer = new VBox(); menuContainer.getStyleClass().add("menu-container"); scrollPane = new PrettyScrollPane(menuContainer); backIconShape = new StackPane(); backIconShape.getStyleClass().add("shape"); backBtn = new Button("", backIconShape); backBtn.getStyleClass().add("icon"); backBtn.setId("back-button"); companyLogo = new Label(); companyLogo.getStyleClass().add("logo"); }
Example 3
Source File: BoardNameDialog.java From HubTurbo with GNU Lesser General Public License v3.0 | 6 votes |
private void createButtons() { ButtonType submitButtonType = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE); getDialogPane().getButtonTypes().addAll(submitButtonType, ButtonType.CANCEL); submitButton = (Button) getDialogPane().lookupButton(submitButtonType); submitButton.addEventFilter(ActionEvent.ACTION, event -> { if (isBoardNameDuplicate(nameField.getText()) && !shouldOverwriteDuplicateBoard()) { event.consume(); } }); submitButton.setId(IdGenerator.getBoardNameSaveButtonId()); setResultConverter(submit -> { if (submit == submitButtonType) { return nameField.getText(); } return null; }); }
Example 4
Source File: ExampleCss.java From chuidiang-ejemplos with GNU Lesser General Public License v3.0 | 6 votes |
private void buildAndShowMainWindow(Stage primaryStage) { primaryStage.setTitle("Hello World!!"); GridPane gridPane = new GridPane(); gridPane.setAlignment(Pos.CENTER); gridPane.setHgap(10); gridPane.setVgap(10); gridPane.setPadding(new Insets(25, 25, 25, 25)); button = new Button("Click me!"); button.setId("TheButton"); gridPane.add(button,1,1); text = new TextField(); gridPane.add(text, 2, 1); clockLabel = new Label(); gridPane.add(clockLabel, 1,2, 2, 1); Scene scene = new Scene(gridPane); primaryStage.setScene(scene); scene.getStylesheets().add(getClass().getResource("/form.css").toExternalForm()); primaryStage.show(); }
Example 5
Source File: CSSFXTesterApp.java From cssfx with Apache License 2.0 | 6 votes |
public Parent buildUI() { BorderPane bp = new BorderPane(); int prefWidth = 300; int prefHeight = 200; Button btnShowBottomBar = new Button("Dynamic bottom bar"); btnShowBottomBar.setId("dynamicBar"); btnShowBottomBar.setOnAction((ae) -> bp.setBottom(createButtonBar())); btnLoadOddCSS = new Button("Load additional CSS"); btnLoadOddCSS.setId("dynamicCSS"); Button btnCreateStage = new Button("Create new stage"); btnCreateStage.setOnAction(ae -> { Stage stage = new Stage(); fillStage(stage); stage.show(); }); btnCreateStage.setId("dynamicStage"); FlowPane topBar = new FlowPane(btnShowBottomBar, btnLoadOddCSS, btnCreateStage); topBar.getStyleClass().addAll("button-bar", "top"); bp.setTop(topBar); bp.setCenter(buildCirclePane(prefWidth, prefHeight)); return bp; }
Example 6
Source File: ToolbarView.java From WorkbenchFX with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public final void initializeParts() { topBox = new HBox(); topBox.setId("top-box"); toolbarControl = new ToolbarControl(); toolbarControl.setId("toolbar-control"); bottomBox = new HBox(); bottomBox.setId("bottom-box"); addIconShape = new StackPane(); addIconShape.getStyleClass().add("shape"); addModuleBtn = new Button("", addIconShape); addModuleBtn.getStyleClass().add("icon"); addModuleBtn.setId("add-button"); menuIconShape = new StackPane(); menuIconShape.getStyleClass().add("shape"); menuBtn = new Button("", menuIconShape); menuBtn.getStyleClass().add("icon"); menuBtn.setId("menu-button"); tabBar = new SelectionStrip<>(); // Reset default sizing from the selectionStrip constructor tabBar.setPrefSize(0, 0); tabBar.setId("tab-bar"); }
Example 7
Source File: ManagerFragment.java From mdict-java with GNU General Public License v3.0 | 5 votes |
private Node new_button(String bI, ResourceBundle bundle, EventHandler<ActionEvent> clicker, Insets padding) { Button btnTmp = new Button(bundle.getString(bI)); btnTmp.setId(bI); btnTmp.setOnAction(clicker); VBox.setMargin(btnTmp, padding); return btnTmp; }
Example 8
Source File: SettingsDialog.java From mdict-java with GNU General Public License v3.0 | 5 votes |
private HBox make_simple_button(String val) { Button btnTmp = new Button(); btnTmp.setId(val); btnTmp.setText(bundle.getString(val)); btnTmp.setOnAction(this); HBox vb1 = new HBox(btnTmp); vb1.setPadding(padding2); return vb1; }
Example 9
Source File: SettingsDialog.java From mdict-java with GNU General Public License v3.0 | 5 votes |
private HBox make_simple_buttons(String...val) { HBox vb1 = new HBox(); vb1.setPadding(padding2); vb1.setSpacing(10); for (String vI:val) { Button btnTmp = new Button(); btnTmp.setId(vI); btnTmp.setText(bundle.getString(vI)); vb1.getChildren().add(btnTmp); btnTmp.setOnAction(this); } return vb1; }
Example 10
Source File: SettingsDialog.java From mdict-java with GNU General Public License v3.0 | 5 votes |
private HBox make_switchable_path_picker(boolean hasChecker, String message, String val, boolean enabled) { ToggleSwitch switcher = null; if(hasChecker){ switcher = new ToggleSwitch(); switcher.setId(message); switcher.selectedProperty().addListener(this); switcher.setSelected(enabled); } TextField pathInput = new TextField(val); HBox.setHgrow(pathInput, Priority.ALWAYS); pathInput.setId(message); pathInput.textProperty().addListener(this); HBox vb1 = new HBox(new Text(bundle.getString(message)), pathInput); if(switcher!=null){ vb1.getChildren().add(0, switcher); vb1.setPadding(padding); }else{ vb1.setPadding(padding2); } vb1.setAlignment(Pos.CENTER_LEFT); boolean b1,b2; if((b1=message.equals(UI.overwrite_browser)) || message.equals(UI.overwrite_pdf_reader)){//add file-picker if(b1) PathInput1=pathInput; else PathInput2=pathInput; Button btnTmp = new Button(bundle.getString(UI.open)); btnTmp.setId(message); btnTmp.setOnAction(this); vb1.getChildren().add(btnTmp); } return vb1; }
Example 11
Source File: MarsNode.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public Button createGreenhouseDialog(Farming farm) { String name = farm.getBuilding().getNickName(); Button b = new Button(name); b.setMaxWidth(Double.MAX_VALUE); List<String> choices = new ArrayList<>(); choices.add("Lettuce"); choices.add("Green Peas"); choices.add("Carrot"); ChoiceDialog<String> dialog = new ChoiceDialog<>("List of Crops", choices); dialog.setTitle(name); dialog.setHeaderText("Plant a Crop"); dialog.setContentText("Choose Your Crop:"); dialog.initOwner(stage); // post the same icon from stage dialog.initStyle(StageStyle.UTILITY); //dialog.initModality(Modality.NONE); b.setPadding(new Insets(20)); b.setId("settlement-node"); b.getStylesheets().add("/fxui/css/settlementnode.css"); b.setOnAction(e->{ // The Java 8 way to get the response value (with lambda expression). Optional<String> selected = dialog.showAndWait(); selected.ifPresent(crop -> System.out.println("Crop added to the queue: " + crop)); }); //ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); //ButtonType buttonTypeOk = new ButtonType("OK", ButtonData.OK_DONE); //dialog.getButtonTypes().setAll(buttonTypeCancel, buttonTypeOk); return b; }
Example 12
Source File: TestLoadImageUsingCss.java From javafxsvg with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected Parent getRootNode() { String css = getClass().getClassLoader().getResource("imagetest.css") .toExternalForm(); Button button = new Button("Test"); button.setId("TestButton"); AnchorPane anchorPane = new AnchorPane(button); anchorPane.getStylesheets().add(css); return anchorPane; }
Example 13
Source File: FormBuilder.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public static Button getIconButton(GlyphIcons icon, String styleClass, String iconSize) { if (icon.fontFamily().equals(MATERIAL_DESIGN_ICONS)) { Button iconButton = MaterialDesignIconFactory.get().createIconButton(icon, "", iconSize, null, ContentDisplay.CENTER); iconButton.setId("icon-button"); iconButton.getGraphic().getStyleClass().add(styleClass); iconButton.setPrefWidth(20); iconButton.setPrefHeight(20); iconButton.setPadding(new Insets(0)); return iconButton; } else { throw new IllegalArgumentException("Not supported icon type"); } }
Example 14
Source File: SettingsMenu.java From iliasDownloaderTool with GNU General Public License v2.0 | 5 votes |
private void toggleButtonColor(ActionEvent event) { Flags flags = Settings.getInstance().getFlags(); Button button = (Button) event.getSource(); if (button.equals(autoLogin)) { if (flags.isAutoLogin()) { flags.setAutoLogin(false); button.setId(null); } else { flags.setAutoLogin(true); button.setId("autoButtonActive"); } return; } if (button.equals(autoUpdate)) { if (flags.autoUpdate()) { flags.setAutoUpdate(false); button.setId(null); } else { flags.setAutoUpdate(true); button.setId("autoButtonActive"); } return; } if (button.equals(connectSecure)) { if (flags.isConnectSecure()) { flags.setConnectSecure(false); button.setId(null); } else { flags.setConnectSecure(true); button.setId("autoButtonActive"); } return; } }
Example 15
Source File: UIEnumMenuItem.java From tcMenu with Apache License 2.0 | 4 votes |
@Override protected int internalInitPanel(GridPane grid, int idx) { idx++; grid.add(new Label("Values"), 0, idx); ObservableList<String> list = FXCollections.observableArrayList(getMenuItem().getEnumEntries()); listView = new ListView<>(list); listView.setEditable(true); listView.setCellFactory(TextFieldListCell.forListView()); listView.setOnEditCommit(t -> { listView.getItems().set(t.getIndex(), t.getNewValue()); }); listView.setMinHeight(100); grid.add(listView, 1, idx, 1, 3); idx+=3; Button addButton = new Button("Add"); addButton.setId("addEnumEntry"); Button removeButton = new Button("Remove"); removeButton.setId("removeEnumEntry"); removeButton.setDisable(true); HBox hbox = new HBox(addButton, removeButton); grid.add(hbox, 1, idx); addButton.setOnAction(event -> { listView.getItems().add("ChangeMe"); listView.getSelectionModel().selectLast(); }); removeButton.setOnAction(event -> { String selectedItem = listView.getSelectionModel().getSelectedItem(); if(selectedItem != null) { list.remove(selectedItem); } }); list.addListener((ListChangeListener<? super String>) observable -> callChangeConsumer()); listView.setId("enumList"); listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> removeButton.setDisable(newValue == null) ); listView.getSelectionModel().selectFirst(); return idx; }
Example 16
Source File: AboutDashboardPane.java From pdfsam with GNU Affero General Public License v3.0 | 4 votes |
@Inject public AboutDashboardPane(Pdfsam pdfsam) { getStyleClass().add("dashboard-container"); VBox left = new VBox(5); addSectionTitle(pdfsam.name(), left); Label copyright = new Label(pdfsam.property(COPYRIGHT)); FontAwesomeIconFactory.get().setIcon(copyright, FontAwesomeIcon.COPYRIGHT); left.getChildren().addAll(new Label(String.format("ver. %s", pdfsam.property(VERSION))), copyright); addHyperlink(null, pdfsam.property(LICENSE_URL), pdfsam.property(LICENSE_NAME), left); addHyperlink(FontAwesomeIcon.HOME, pdfsam.property(HOME_URL), pdfsam.property(HOME_LABEL), left); addHyperlink(FontAwesomeIcon.RSS_SQUARE, pdfsam.property(FEED_URL), DefaultI18nContext.getInstance().i18n("Subscribe to the official news feed"), left); addSectionTitle(DefaultI18nContext.getInstance().i18n("Environment"), left); Label runtime = new Label(String.format("%s %s", System.getProperty("java.runtime.name"), System.getProperty("java.runtime.version"))); Label vendor = new Label( String.format(DefaultI18nContext.getInstance().i18n("Vendor: %s"), System.getProperty("java.vendor"))); Label runtimePath = new Label(String.format(DefaultI18nContext.getInstance().i18n("Java runtime path: %s"), System.getProperty("java.home"))); Label fx = new Label(String.format(DefaultI18nContext.getInstance().i18n("JavaFX runtime version %s"), System.getProperty("javafx.runtime.version"))); Label memory = new Label(DefaultI18nContext.getInstance().i18n("Max memory {0}", FileUtils.byteCountToDisplaySize(Runtime.getRuntime().maxMemory()))); Button copyButton = new Button(DefaultI18nContext.getInstance().i18n("Copy to clipboard")); FontAwesomeIconFactory.get().setIcon(copyButton, FontAwesomeIcon.COPY); copyButton.getStyleClass().addAll(Style.BUTTON.css()); copyButton.setId("copyEnvDetails"); copyButton.setOnAction(a -> { ClipboardContent content = new ClipboardContent(); writeContent(Arrays.asList(pdfsam.name(), pdfsam.property(VERSION), runtime.getText(), vendor.getText(), runtimePath.getText(), fx.getText(), memory.getText())).to(content); Clipboard.getSystemClipboard().setContent(content); }); left.getChildren().addAll(runtime, vendor, runtimePath, fx, memory, copyButton); VBox right = new VBox(5); addSectionTitle(DefaultI18nContext.getInstance().i18n("Support"), right); addHyperlink(FontAwesomeIcon.BUG, pdfsam.property(TRACKER_URL), DefaultI18nContext.getInstance().i18n("Bug and feature requests"), right); addHyperlink(FontAwesomeIcon.QUESTION_CIRCLE, pdfsam.property(SUPPORT_URL), DefaultI18nContext.getInstance().i18n("Support"), right); addHyperlink(FontAwesomeIcon.BOOK, pdfsam.property(DOCUMENTATION_URL), DefaultI18nContext.getInstance().i18n("Documentation"), right); addSectionTitle(DefaultI18nContext.getInstance().i18n("Contribute"), right); addHyperlink(FontAwesomeIcon.GITHUB, pdfsam.property(SCM_URL), DefaultI18nContext.getInstance().i18n("Fork PDFsam on GitHub"), right); addHyperlink(FontAwesomeIcon.FLAG_ALT, pdfsam.property(TRANSLATE_URL), DefaultI18nContext.getInstance().i18n("Translate"), right); addHyperlink(FontAwesomeIcon.DOLLAR, pdfsam.property(DONATE_URL), DefaultI18nContext.getInstance().i18n("Donate"), right); addSectionTitle(DefaultI18nContext.getInstance().i18n("Social"), right); addHyperlink(FontAwesomeIcon.TWITTER_SQUARE, pdfsam.property(TWITTER_URL), DefaultI18nContext.getInstance().i18n("Follow us on Twitter"), right); addHyperlink(FontAwesomeIcon.FACEBOOK_SQUARE, pdfsam.property(FACEBOOK_URL), DefaultI18nContext.getInstance().i18n("Like us on Facebook"), right); getChildren().addAll(left, right); }