List of usage examples for javafx.scene.control Button Button
public Button()
From source file:clientechat.TestList.java
@Override public void start(Stage primaryStage) { WebView wv = new WebView(); Button btn = new Button(); TextField textField = new TextField(); VBox vb = new VBox(); WebEngine appendEngine = wv.getEngine(); btn.setOnAction(new EventHandler<ActionEvent>() { @Override/*from ww w . j a v a2 s. c o m*/ public void handle(ActionEvent event) { executejQuery(appendEngine, "$('#content').append(\"<p align=right><b>World!" + escapeHtml(textField.getText()) + "<b><p>\");"); executejQuery(appendEngine, "$(\"html, body\").animate({ scrollTop: $(document).height()-$(window).height() });"); } }); wv.getEngine().loadContent( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" + "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" + "<head>\n" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" + "<title>Documento sin ttulo</title>\n" + "</head>\n" + "\n" + "<body id=\"content\">\n" + " \n" + "</body>\n" + "</html>"); vb.getChildren().addAll(wv, btn, textField); Scene scene = new Scene(vb); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }
From source file:ijfx.ui.inputharvesting.FileWidgetFX.java
@Override public void set(WidgetModel model) { super.set(model); button = new Button(); binding = new FileButtonBinding(button); FileButtonBinding.Mode mode = null;// www . j a v a 2s. c o m // first we try to get the adaptive widget style // to get the type and configure the file dialog if (model.getItem() != null) { String style = model.getItem().getWidgetStyle(); if (style != null) { style = style.toLowerCase(); if (style.contains("open")) { mode = FileButtonBinding.Mode.OPEN; binding.setExtensions(extractExtensions(style)); } else if (style.contains("save")) { mode = FileButtonBinding.Mode.SAVE; binding.setExtensions(extractExtensions(style)); } } } // otherwise if (mode == null) { if (model.isStyle(DIRECTORY_STYLE)) { mode = FileButtonBinding.Mode.FOLDER; } else if (model.isStyle(SAVE_STYLE)) { mode = FileButtonBinding.Mode.SAVE; } else { mode = FileButtonBinding.Mode.OPEN; } } binding.setMode(mode); bindProperty(binding.fileProperty()); }
From source file:vkmanager.controller.PhotosDetailedController.java
public void showPhotosFromAlbum(VKPhotoAlbum album, int userId) { this.album = album; idForDownload = album.getId();//from w w w .j a v a 2 s. c o m albumDescription.setText(album.getDescription()); photos = vkapi.getPhotosFromAlbum(idForDownload, userId); int i = 0; int j = 0; gridPaneDetailed.addRow(0); for (VKPhoto photo : photos) { Image photoThumbLink = new Image(photo.getLink_s()); ImageView photoThumb = new ImageView(photoThumbLink); photoThumb.setFitHeight(160); photoThumb.setFitWidth(240); photoThumb.setPreserveRatio(true); photoThumb.setSmooth(true); photoThumb.setCache(true); Button photoButt = new Button(); photoButt.setGraphic(photoThumb); photoButt.setStyle("-fx-background-color: white;"); photoButt.setMinSize(240, 160); photoButt.setAlignment(Pos.CENTER); BorderPane bp = new BorderPane(null, photoButt, null, null, null); gridPaneDetailed.add(bp, j, i); j++; if (j == 3) { i++; j = 0; gridPaneDetailed.addRow(i); } } }
From source file:nl.mvdr.umvc3replayanalyser.gui.ErrorMessagePopup.java
/** * Handles an exception that caused program startup to fail, by showing an error message to the user. * // ww w. j a v a 2 s . com * @param title * title for the dialog * @param errorMessage * error message * @param stage * stage in which to show the error message * @param exception * exception that caused the error */ public static void show(String title, String errorMessage, final Stage stage, Exception exception) { log.info("Showing error message dialog to indicate that startup failed."); // Create the error dialog programatically without relying on FXML, to minimize the chances of further failure. stage.setTitle(title); // Error message text. Text text = new Text(errorMessage); // Text area containing the stack trace. Not visible by default. String stackTrace; if (exception != null) { stackTrace = ExceptionUtils.getStackTrace(exception); } else { stackTrace = "No more details available."; } final TextArea stackTraceArea = new TextArea(stackTrace); stackTraceArea.setEditable(false); stackTraceArea.setVisible(false); // Details button for displaying the stack trace. Button detailsButton = new Button(); detailsButton.setText("Details"); detailsButton.setOnAction(new EventHandler<ActionEvent>() { /** {@inheritDoc} */ @Override public void handle(ActionEvent event) { log.info("User clicked Details."); stackTraceArea.setVisible(!stackTraceArea.isVisible()); } }); // OK button for closing the dialog. Button okButton = new Button(); okButton.setText("OK"); okButton.setOnAction(new EventHandler<ActionEvent>() { /** {@inheritDoc} */ @Override public void handle(ActionEvent event) { log.info("User clicked OK, closing the dialog."); stage.close(); } }); // Horizontal box containing the buttons, to make sure they are always centered. HBox buttonsBox = new HBox(5); buttonsBox.getChildren().add(detailsButton); buttonsBox.getChildren().add(okButton); buttonsBox.setAlignment(Pos.CENTER); // Layout constraints. AnchorPane.setTopAnchor(text, Double.valueOf(5)); AnchorPane.setLeftAnchor(text, Double.valueOf(5)); AnchorPane.setRightAnchor(text, Double.valueOf(5)); AnchorPane.setTopAnchor(stackTraceArea, Double.valueOf(31)); AnchorPane.setLeftAnchor(stackTraceArea, Double.valueOf(5)); AnchorPane.setRightAnchor(stackTraceArea, Double.valueOf(5)); AnchorPane.setBottomAnchor(stackTraceArea, Double.valueOf(36)); AnchorPane.setLeftAnchor(buttonsBox, Double.valueOf(5)); AnchorPane.setRightAnchor(buttonsBox, Double.valueOf(5)); AnchorPane.setBottomAnchor(buttonsBox, Double.valueOf(5)); AnchorPane root = new AnchorPane(); root.getChildren().addAll(text, stackTraceArea, buttonsBox); stage.setScene(new Scene(root)); // Use a standard program icon if possible. try { stage.getIcons().add(Icons.get().getRandomPortrait()); } catch (IllegalStateException e) { log.warn("Failed to load icon for error dialog; proceeding with default JavaFX icon.", e); } stage.show(); // Default size should also be the minimum size. stage.setMinWidth(stage.getWidth()); stage.setMinHeight(stage.getHeight()); log.info("Error dialog displayed."); }
From source file:photobooth.views.EmailPane.java
private void addXButton() { Button button = new Button(); try {//from w w w . ja v a2 s.co m button.setGraphic( new ImageView(new Image(getClass().getResource("/photobooth/images/exit.png").openStream()))); } catch (IOException ex) { Logger.getLogger(EmailPane.class.getName()).log(Level.SEVERE, null, ex); } button.setStyle("-fx-background-color: transparent;"); button.setLayoutX(730); button.setLayoutY(10); button.setMaxSize(50, 50); button.setMinSize(50, 50); button.getStyleClass().add("blueButton"); this.getChildren().add(button); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { t.cancel(); t.purge(); Global.getInstance().setSceneRoot(HomePane.getInstance()); } }); }
From source file:isbnfilter.ISBNFilter.java
@Override public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Say 'Hello World'"); btn.setOnAction(new EventHandler<ActionEvent>() { @Override/*from w w w.ja v a 2 s. co m*/ public void handle(ActionEvent event) { System.out.println("Hello World!"); try { List<String[]> isbns = readFile(primaryStage); //Lee y mete todo en un string ISBNConverter classISBN = new ISBNConverter(); classISBN.createNewFile(isbns); } catch (IOException | JSONException ex) { Logger.getLogger(ISBNFilter.class.getName()).log(Level.SEVERE, null, ex); } } }); StackPane root = new StackPane(); root.getChildren().add(btn); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }
From source file:ubicrypt.ui.ctrl.providers.ProvidersController.java
@Override public void initialize(URL url, ResourceBundle resourceBundle) { String fxml = substringBefore(substringAfterLast(url.getFile(), "/"), ".fxml"); navigator = new StackNavigator(root, fxml, controllerFactory); providers.setCellFactory(listView -> new ListCell<ProviderItem>() { @Override// w ww . j av a2s . co m protected void updateItem(ProviderItem pi, boolean empty) { super.updateItem(pi, empty); if (empty) { setText(null); setGraphic(null); return; } setContextMenu(pi.getContextMenu()); Platform.runLater(() -> setGraphic(pi.getGraphics())); } }); providerDescriptors.stream().forEach(pd -> { Button button = new Button(); Image img = pd.getLogo().getImage(); ImageView view = new ImageView(img); view.setFitWidth(30.0); view.setPickOnBounds(true); view.setPreserveRatio(true); button.setGraphic(view); button.setOnMouseClicked(mouseEvent -> { log.debug("adding provider :{}", pd.getCode()); navigator.browse(format("provider/%s", pd.getCode())); }); button.setTooltip(new Tooltip("Add " + pd.getDescription())); availableProviders.getItems().add(button); }); //provider status events providerEvent.subscribe(pevent -> { UbiProvider provider = pevent.getHook().getProvider(); if (!providers.getItems().stream().filter(pi -> pi.getProvider().equals(provider)).findFirst() .isPresent()) { log.info("add new provider:{}", pevent.getHook().getProvider()); String code = providerDescriptors.stream().filter(pd -> pd.getType() == provider.getClass()) .map(ProviderDescriptor::getCode).findFirst().get(); final ProviderItem providerItem = new ProviderItem(provider, providerDescriptors.stream() .filter(pd -> pd.getType() == provider.getClass()).findFirst().get(), providerRemover, navigator); providers.getItems().add(providerItem); pevent.getHook().getStatusEvents().subscribe(providerItem::changeStatus); } switch (pevent.getEvent()) { case removed: //TODO: remove provider break; default: log.warn("unmanaged event:{}", pevent.getEvent()); } providers.getItems().stream().filter(pi -> pi.getProvider().equals(provider)).findFirst() .ifPresent(pi -> pi.changeStatus(pevent.getEvent())); }); }
From source file:calendarioSeries.vistas.MainViewController.java
@FXML public void initialize() { next = new Button(); next.setId("next"); previous = new Button(); previous.setId("previous"); imagenes.widthProperty().addListener(new ChangeListener<Number>() { @Override/* w w w. j a va 2s .c om*/ public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { imagenes.hgapProperty().set(newSceneWidth.doubleValue() / 88); } }); populateImagenes(); showDetallesMes(mesActual); }
From source file:de.rkl.tools.tzconv.TimezoneConverter.java
private Node createTemplateFileSelection() { final Button templateFileChooserButton = new Button(); templateFileChooserButton.setText("Select template..."); templateFileChooserButton.setOnAction( event -> applicationModel.templateFile.setValue(createTemplateFileChooser().showOpenDialog(null))); return templateFileChooserButton; }
From source file:fruitproject.FruitProject.java
public void first(final Stage primaryStage) { GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);//www . j a v a 2 s . c o m grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); rows = 0; addPairs.clear(); Text lb = new Text(); lb.setText("J-Fruit"); //lb.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20)); grid.add(lb, 1, 0); final ToggleGroup grp = new ToggleGroup(); RadioButton rb1 = new RadioButton(); rb1.setText("Add Fruit file"); rb1.setUserData("add"); rb1.setToggleGroup(grp); rb1.setSelected(true); grid.add(rb1, 1, 1); RadioButton rb2 = new RadioButton(); rb2.setText("Load Fruit file"); rb2.setUserData("load"); rb2.setToggleGroup(grp); grid.add(rb2, 1, 2); Label label1 = new Label("Enter File Name:"); final TextField tfFilename = new TextField(); final HBox hb = new HBox(); hb.getChildren().addAll(label1, tfFilename); hb.setSpacing(10); hb.setVisible(false); tfFilename.setText(""); grid.add(hb, 1, 3); grp.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) { if (grp.getSelectedToggle() != null) { // System.out.println(grp.getSelectedToggle().getUserData().toString()); if (grp.getSelectedToggle().getUserData().toString() == "load") hb.setVisible(true); else { hb.setVisible(false); tfFilename.setText(""); } } } }); if (rb2.isSelected() == true) { hb.setVisible(true); } Button btn = new Button(); btn.setText("GO"); grid.add(btn, 1, 4); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); if (tfFilename.getText() == "") second(""); else second(tfFilename.getText()); primaryStage.close(); } }); //StackPane root = new StackPane(); //root.getChildren().add(lb); //root.getChildren().add(rb1); //root.getChildren().add(rb2); //root.getChildren().add(btn); Scene scene = new Scene(grid, 400, 450); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }