List of usage examples for javafx.scene.control Button Button
public Button(String text)
From source file:net.sf.anathema.framework.presenter.action.about.AnathemaAboutAction.java
private void showCloseButton(MigPane parent, final Stage aboutStage) { Button close = new Button(getString("Help.AboutDialog.CloseButton")); close.setOnAction(new EventHandler<ActionEvent>() { @Override/*from www . j a va 2 s . co m*/ public void handle(ActionEvent actionEvent) { closeDialog(aboutStage); } }); parent.add(close, new CC().dockSouth().alignX("center")); }
From source file:account.management.controller.inventory.InsertStockController.java
public void addRow() { ComboBox<Product> select_item = new ComboBox(); select_item.setPromptText("Select Item"); select_item.setPrefWidth(190);//w w w. jav a 2s .c o m select_item.setPrefHeight(25); new AutoCompleteComboBoxListener<>(select_item); select_item.setOnHiding((e) -> { Product a = select_item.getSelectionModel().getSelectedItem(); select_item.setEditable(false); select_item.getSelectionModel().select(a); }); select_item.setOnShowing((e) -> { select_item.setEditable(true); }); TextField qty = new TextField(); qty.setPromptText("Quantity"); qty.setPrefWidth(97); qty.setPrefHeight(25); TextField rate = new TextField(); rate.setPrefWidth(100); rate.setPrefHeight(25); if (this.voucher_type.getSelectionModel().getSelectedItem().equals("Purchase")) { rate.setPromptText("Purchase Rate"); } else { rate.setPromptText("Sell Rate"); } Button del = new Button("Delete"); HBox row = new HBox(); row.getChildren().addAll(select_item, qty, rate, del); row.setSpacing(10); row.setPadding(new Insets(0, 0, 0, 15)); this.conatiner.getChildren().add(row); del.setOnAction((e) -> { this.conatiner.getChildren().remove(row); this.add_row.setDisable(false); calculateTotal(); }); select_item.getItems().addAll(this.products_list); select_item.setOnAction((e) -> { qty.setText("0"); if (this.voucher_type.getSelectionModel().getSelectedItem().equals("Purchase")) { rate.setText(String.valueOf(select_item.getSelectionModel().getSelectedItem().getLast_p_rate())); } else { rate.setText(String.valueOf(select_item.getSelectionModel().getSelectedItem().getLast_s_rate())); } calculateTotal(); }); qty.setOnKeyReleased((e) -> { calculateTotal(); }); rate.setOnKeyReleased((e) -> { calculateTotal(); }); if (this.conatiner.getChildren().size() >= 8) { this.add_row.setDisable(true); return; } }
From source file:org.jacp.demo.perspectives.ContactPerspective.java
@PostConstruct /**// ww w . j av a2 s . com * create buttons in tool bars; menu entries */ public void PostConstructPerspective(final FXComponentLayout layout, final ResourceBundle resourceBundle) { LOGGER.debug("PostConstructPerspective ressource:" + resourceBundle); // create button in toolbar; button should switch top and bottom id's final JACPToolBar north = layout.getRegisteredToolBar(NORTH); final JACPToolBar south = layout.getRegisteredToolBar(SOUTH); final JACPToolBar west = layout.getRegisteredToolBar(WEST); final JACPToolBar east = layout.getRegisteredToolBar(EAST); final Button custom = new Button("switch"); custom.setTooltip(new Tooltip("Switch Components")); custom.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent e) { context.send(SWITCH_MESSAGE); } }); north.addOnEnd(context.getId(), custom); // TEST OPTIONBUTTON ON NORTH north.addOnEnd(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10)); north.addToCenter(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10)); north.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, BOTTOM, 10)); west.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT)); west.addToCenter(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT)); west.addOnEnd(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("another Button", layout, RIGHT)); east.addOnEnd(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT)); east.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT)); east.addToCenter(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("right Button", layout, LEFT)); south.add(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP)); south.addToCenter(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP)); south.addOnEnd(context.getId(), JACPOptionButtonCreator.createDefaultOptionButton("bottom Button", layout, TOP)); JACPHoverMenu menu = new JACPHoverMenu("Hovermenu", layout); VBox p = new VBox(); p.setPadding(new Insets(10)); Button b = new Button("HELLO"); CheckBox check = new CheckBox("checkbox"); p.getChildren().addAll(b, check); ColorPicker picker = new ColorPicker(); menu.getContentPane().getChildren().add(p); north.addToCenter(context.getId(), menu); north.addToCenter(context.getId(), picker); }
From source file:com.scndgen.legends.windows.WindowAbout.java
public WindowAbout() { super(StageStyle.UNDECORATED); try {//from w w w . j av a2 s . c o m about = IOUtils.toString( Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtAbout.txt"), Charset.defaultCharset()); licenseText = IOUtils.toString( Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtLicense.txt"), Charset.defaultCharset()); changeLog = IOUtils.toString( Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtChangelog.txt"), Charset.defaultCharset()); sourceCode = IOUtils.toString( Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtSourceCode.txt"), Charset.defaultCharset()); } catch (Exception ex) { ex.printStackTrace(System.err); } txtAbout = new TextArea(""); txtAbout.setText(about); txtAbout.setEditable(false); txtAbout.setWrapText(true); scrlAbout = new ScrollPane(txtAbout); txtLicense = new TextArea(""); txtLicense.setText(licenseText); txtLicense.setEditable(false); txtLicense.setWrapText(true); scrlLicense = new ScrollPane(txtLicense); txtChangeLog = new TextArea(""); txtChangeLog.setText(changeLog); txtChangeLog.setEditable(false); txtChangeLog.setWrapText(true); scrlChangeLog = new ScrollPane(txtChangeLog); txtSourceCode = new TextArea(""); txtSourceCode.setText(sourceCode); txtSourceCode.setEditable(false); txtSourceCode.setWrapText(true); scrlSourceCode = new ScrollPane(txtSourceCode); Tab tabAbout = new Tab("About"); tabAbout.setClosable(false); Tab tabLicense = new Tab("License"); tabLicense.setClosable(false); Tab tabDevelop = new Tab("Develop"); tabDevelop.setClosable(false); Tab tabChangelog = new Tab("Changelog"); tabChangelog.setClosable(false); tabAbout.setContent(scrlAbout); tabLicense.setContent(scrlLicense); tabDevelop.setContent(scrlSourceCode); tabChangelog.setContent(scrlChangeLog); tabPane = new TabPane(); tabPane.getTabs().add(tabAbout); tabPane.getTabs().add(tabLicense); tabPane.getTabs().add(tabChangelog); tabPane.getTabs().add(tabDevelop); btnOk = new Button("OK"); btnOk.setOnAction(event -> { close(); }); VBox vBox = new VBox(); vBox.setSpacing(4); vBox.getChildren().add(tabPane); vBox.getChildren().add(btnOk); setTitle(Language.get().get(57)); setScene(new Scene(vBox)); setResizable(false); initModality(Modality.APPLICATION_MODAL); show(); }
From source file:dsfixgui.view.DSFUnsafeSettingsPane.java
private void initialize() { //Basic layout this.setFitToWidth(true); spacerColumn = new ColumnConstraints(); spacerColumn.setFillWidth(true);/*from w w w . j av a2 s . c om*/ spacerColumn.setPercentWidth(3.0); primaryColumn = new ColumnConstraints(); primaryColumn.setFillWidth(true); primaryColumn.setPercentWidth(95.0); primaryPane = new GridPane(); primaryPane.getColumnConstraints().addAll(spacerColumn, primaryColumn); primaryVBox = new VBox(); primaryVBox.getStyleClass().add("spacing_15"); primaryPane.add(primaryVBox, 1, 0); titleLabel = new Label(UNSAFE_OPS.toUpperCase() + " " + SETTINGS.toUpperCase()); titleLabel.getStyleClass().addAll("settings_title", "red_text"); titleLabel.setTooltip(new Tooltip(UNSAFE_TT)); titleBar = new HBox(); titleBar.setAlignment(Pos.CENTER); titleBar.getChildren().add(titleLabel); restoreDefaultsBar = new HBox(); restoreDefaultsBar.setAlignment(Pos.CENTER); restoreDefaultsBar.setSpacing(5.0); applySettingsButton = new Button(APPLY_SETTINGS); restoreDefaultsButton = new Button(RESTORE_DEFAULTS); applySettingsButton.getStyleClass().add("translate_y_4"); restoreDefaultsButton.getStyleClass().add("translate_y_4"); restoreDefaultsBar.getChildren().addAll(applySettingsButton, restoreDefaultsButton); spacerHBox = new HBox(); spacerHBox.setMinHeight(10.0); bottomSpacerHBox = new HBox(); bottomSpacerHBox.setMinHeight(10.0); /////////////////////SETTINGS PANES///////////////////// // // //Force Window Modes windowModePane = new FlowPane(); windowModePane.getStyleClass().add("settings_pane"); windowModeLabel = new Label(FORCE_WINDOW_MODE_LABEL + " "); windowModeLabel.getStyleClass().addAll("bold_text", "font_12_pt"); windowModeChoice = new ToggleGroup(); neitherWindowMode = new RadioButton(WINDOW_MODES[0] + " "); neitherWindowMode.setToggleGroup(windowModeChoice); forceWindowed = new RadioButton(WINDOW_MODES[1]); forceWindowed.setToggleGroup(windowModeChoice); forceFullscreen = new RadioButton(WINDOW_MODES[2]); forceFullscreen.setToggleGroup(windowModeChoice); if (config.forceWindowed.get() == 0 && config.forceFullscreen.get() == 0) { neitherWindowMode.setSelected(true); } else if (config.forceWindowed.get() == 1) { forceWindowed.setSelected(true); config.forceFullscreen.set(0); } else { forceFullscreen.setSelected(true); } windowModePane.getChildren().addAll(windowModeLabel, neitherWindowMode, forceWindowed, forceFullscreen); // //Toggle Vsync vsyncPane = new FlowPane(); vsyncPane.getStyleClass().add("settings_pane"); vsyncLabel = new Label(VSYNC_LABEL + " "); vsyncLabel.getStyleClass().addAll("bold_text", "font_12_pt"); vsyncLabel.setTooltip(new Tooltip(VSYNC_TT)); vsyncPicker = new ComboBox(FXCollections.observableArrayList(DISABLE_ENABLE)); if (config.enableVsync.get() == 0) { vsyncPicker.setValue(vsyncPicker.getItems().get(0)); } else { vsyncPicker.setValue(vsyncPicker.getItems().get(1)); } vsyncPane.getChildren().addAll(vsyncLabel, vsyncPicker); // //Fullscreen Refresh Rate refreshRatePane = new FlowPane(); refreshRatePane.getStyleClass().add("settings_pane"); refreshRateLabel = new Label(REFRESH_RATE_LABEL + " "); refreshRateLabel.getStyleClass().addAll("bold_text", "font_12_pt"); refreshRateLabel.setTooltip(new Tooltip(FULLSCREEN_HZ_TT)); refreshRateField = new TextField("" + config.fullscreenHz.get()); refreshRateField.getStyleClass().add("settings_text_field"); refreshRatePane.getChildren().addAll(refreshRateLabel, refreshRateField); // primaryVBox.getChildren().addAll(titleBar, restoreDefaultsBar, spacerHBox, windowModePane, vsyncPane, refreshRatePane, bottomSpacerHBox); initializeEventHandlers(); this.setContent(primaryPane); }
From source file:photobooth.views.ExplorerPane.java
private void init(String dir, int offset, int limit, int directoryLevel) { this.getChildren().removeAll(this.getChildren()); this.dir = dir; this.offset = offset; this.limit = limit; this.directoryLevel = directoryLevel; try {/* w w w. j av a 2 s . c om*/ addXButton(); } catch (IOException ex) { Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex); } if (directoryLevel > 0) { try { addUpButton(); } catch (IOException ex) { Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex); } } addLabel(); TilePane tile = new TilePane(); tile.setHgap(12); tile.setVgap(12); File folder = new File(dir); File[] listOfDirs = folder.listFiles(new FileFilter() { @Override public boolean accept(File file) { return file.isDirectory(); } }); File[] allFileAndDiresctoies = new File[0]; if (listOfDirs != null) { Arrays.sort(listOfDirs); File[] listOfImages = folder.listFiles(new FileFilter() { @Override public boolean accept(File file) { String ext = FilenameUtils.getExtension(file.getAbsolutePath()); return ext.equalsIgnoreCase("jpg") || ext.equalsIgnoreCase("png"); } }); Arrays.sort(listOfImages); allFileAndDiresctoies = new File[listOfDirs.length + listOfImages.length]; System.arraycopy(listOfDirs, 0, allFileAndDiresctoies, 0, listOfDirs.length); System.arraycopy(listOfImages, 0, allFileAndDiresctoies, listOfDirs.length, listOfImages.length); File[] subArray = new File[limit]; int countToCopy = limit; if (offset + limit > allFileAndDiresctoies.length) { countToCopy -= offset + limit - allFileAndDiresctoies.length; } System.arraycopy(allFileAndDiresctoies, offset, subArray, 0, countToCopy); for (final File file : subArray) { if (file == null) { break; } if (file.isFile()) { tile.getChildren().add(createImageView(file)); } else { Button button = new Button(file.getName()); button.setMaxSize(100, 100); button.setMinSize(100, 100); button.setWrapText(true); button.getStyleClass().add("folderButton"); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Global.getInstance().setSceneRoot(LoadingPane.getInstance()); Platform.runLater(() -> { new Thread(new Runnable() { @Override public void run() { ExplorerPane.getInstance().setDir(file.getAbsolutePath(), 0, limit, directoryLevel + 1); Global.getInstance().setSceneRoot(ExplorerPane.getInstance()); } }).start(); }); } }); tile.getChildren().add(button); } } } this.getChildren().add(tile); tile.setMinWidth(670); tile.setMaxWidth(670); tile.setLayoutX(65); tile.setLayoutY(70); tile.setMaxHeight(390); if (allFileAndDiresctoies.length > offset + limit) { try { addNextButton(); } catch (IOException ex) { Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex); } } if (offset > 0) { try { addPrevButton(); } catch (IOException ex) { Logger.getLogger(ExplorerPane.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java
private void openAccountManager() { //Window Crap Stage accountManagerStage = new Stage(); accountManagerStage.setTitle("Starbound Server Account Manager"); GridPane gp = new GridPane(); gp.setAlignment(Pos.CENTER);//from w w w .ja v a2s .c om gp.setVgap(10); gp.setHgap(10); gp.setPadding(new Insets(25, 25, 25, 25)); Text title = new Text("Starbound Account Manager"); title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20)); gp.add(title, 0, 0, 2, 1); ListView<String> user_list = new ListView<String>(); ObservableList<String> user_list_o = FXCollections.observableArrayList(users); user_list.setItems(user_list_o); user_list.setPrefHeight(50); ListView<String> banned_users_list = new ListView<String>(); ObservableList<String> banned_users_list_o = FXCollections.observableArrayList(banned_usernames); banned_users_list.setItems(banned_users_list_o); banned_users_list.setPrefHeight(50); ListView<String> banned_ips_list = new ListView<String>(); ObservableList<String> banned_ips_list_o = FXCollections.observableArrayList(banned_ips); banned_ips_list.setItems(banned_ips_list_o); banned_ips_list.setPrefHeight(50); ListView<String> banned_playernames_list = new ListView<String>(); ObservableList<String> banned_playernames_list_o = FXCollections.observableArrayList(banned_playernames); banned_playernames_list.setItems(banned_playernames_list_o); banned_playernames_list.setPrefHeight(50); Label user_list_l = new Label("Current Users"); Label banned_users_list_l = new Label("Banned Users"); Label banned_ips_list_l = new Label("Banned IP's"); Label banned_playernames_list_l = new Label("Banned Player Names"); Button add_user = new Button("Add User"); Button add_banned_user = new Button("Add Banned User"); Button add_banned_ip = new Button("Add Banned IP"); Button add_banned_playername = new Button("Add Banner Playername"); Button remove_user = new Button("Remove User"); Button remove_banned_user = new Button("Remove Banned User"); Button remove_banned_ip = new Button("Remove Banned IP"); Button remove_banned_playername = new Button("Remove Banner Playername"); HBox userbox = new HBox(); userbox.setAlignment(Pos.BOTTOM_LEFT); userbox.getChildren().addAll(add_user, remove_user); userbox.setSpacing(5); HBox b_userbox = new HBox(); b_userbox.setAlignment(Pos.BOTTOM_LEFT); b_userbox.getChildren().addAll(add_banned_user, remove_banned_user); b_userbox.setSpacing(5); HBox b_ipbox = new HBox(); b_ipbox.setAlignment(Pos.BOTTOM_LEFT); b_ipbox.getChildren().addAll(add_banned_ip, remove_banned_ip); b_ipbox.setSpacing(5); HBox b_playerbox = new HBox(); b_playerbox.setAlignment(Pos.BOTTOM_LEFT); b_playerbox.getChildren().addAll(add_banned_playername, remove_banned_playername); b_playerbox.setSpacing(5); Button save = new Button("Save Config"); save.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { save(); } }); add_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createAccount(user_list); } }); add_banned_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedUser(banned_users_list); } }); add_banned_ip.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedIP(banned_ips_list); } }); add_banned_playername.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { createBannedPlayername(banned_playernames_list); } }); remove_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { users.remove(user_list.getSelectionModel().getSelectedItem()); user_list.setItems(FXCollections.observableArrayList(users)); } }); remove_banned_user.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_usernames.remove(banned_users_list.getSelectionModel().getSelectedItem()); banned_users_list.setItems(FXCollections.observableArrayList(banned_usernames)); } }); remove_banned_ip.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_ips.remove(banned_ips_list.getSelectionModel().getSelectedItem()); banned_ips_list.setItems(FXCollections.observableArrayList(banned_ips)); } }); remove_banned_playername.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { banned_playernames.remove(banned_playernames_list.getSelectionModel().getSelectedItem()); banned_playernames_list.setItems(FXCollections.observableArrayList(banned_playernames)); } }); gp.add(user_list_l, 0, 1); gp.add(user_list, 0, 2); gp.add(userbox, 0, 3); gp.add(banned_users_list_l, 0, 4); gp.add(banned_users_list, 0, 5); gp.add(b_userbox, 0, 6); gp.add(banned_ips_list_l, 0, 7); gp.add(banned_ips_list, 0, 8); gp.add(b_ipbox, 0, 9); gp.add(banned_playernames_list_l, 0, 10); gp.add(banned_playernames_list, 0, 11); gp.add(b_playerbox, 0, 12); gp.add(save, 0, 13); Scene sc = new Scene(gp, 800 / 2, 600); accountManagerStage.setScene(sc); accountManagerStage.show(); }
From source file:Main.java
private void createClipList(GridPane grid) { final VBox vbox = new VBox(30); vbox.setAlignment(Pos.TOP_CENTER);//from w ww . jav a 2 s . c om final Label clipLabel = new Label("Code Monkey To-Do List:"); clipLabel.setId("clipLabel"); final Button getUpButton = new Button("Get Up, Get Coffee"); getUpButton.setPrefWidth(300); getUpButton.setOnAction(createPlayHandler(coffeeClip)); final Button goToJobButton = new Button("Go to Job"); goToJobButton.setPrefWidth(300); goToJobButton.setOnAction(createPlayHandler(jobClip)); final Button meetingButton = new Button("Have Boring Meeting"); meetingButton.setPrefWidth(300); meetingButton.setOnAction(createPlayHandler(meetingClip)); final Hyperlink link = new Hyperlink("About Code Monkey..."); link.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { WebView wv = new WebView(); wv.getEngine().load("http://www.jonathancoulton.com/2006/04/14/" + "thing-a-week-29-code-monkey/"); Scene scene = new Scene(wv, 720, 480); Stage stage = new Stage(); stage.setTitle("Code Monkey"); stage.setScene(scene); stage.show(); } }); vbox.getChildren().addAll(clipLabel, getUpButton, goToJobButton, meetingButton, link); GridPane.setHalignment(vbox, HPos.CENTER); GridPane.setHgrow(vbox, Priority.ALWAYS); GridPane.setVgrow(vbox, Priority.ALWAYS); grid.add(vbox, 0, 0, GridPane.REMAINING, 1); }
From source file:Main.java
private HBox addHBox() { HBox hbox = new HBox(); hbox.setPadding(new Insets(15, 12, 15, 12)); hbox.setSpacing(10); // Gap between nodes hbox.setStyle("-fx-background-color: #336699;"); Button buttonCurrent = new Button("Current"); buttonCurrent.setPrefSize(100, 20);// w w w.j ava2 s .com Button buttonProjected = new Button("Projected"); buttonProjected.setPrefSize(100, 20); hbox.getChildren().addAll(buttonCurrent, buttonProjected); return hbox; }
From source file:net.thirdy.blackmarket.controls.ModSelectionPane.java
private Button addButton() { Button add = new Button("Add"); add.setOnAction(e -> {//www . j a v a 2 s .com modMappingTable.getSelectionModel().getSelectedItems().stream() .forEachOrdered(mm -> modsListView.getItems().add(new Mod(mm))); }); return add; }