List of usage examples for javafx.event EventHandler EventHandler
EventHandler
From source file:org.jacp.demo.components.ContactAddDialog.java
private void createAddContactDialog() { final VBox box = new VBox(); box.getStyleClass().add("jacp-option-pane"); box.setMaxSize(300, Region.USE_PREF_SIZE); // the title//from w w w.j a v a2s .c o m final Label title = new Label("Add new category"); title.setId(GlobalConstants.CSSConstants.ID_JACP_CUSTOM_TITLE); VBox.setMargin(title, new Insets(2, 2, 10, 2)); final HBox hboxInput = new HBox(); final Label nameLabel = new Label("category name:"); HBox.setMargin(nameLabel, new Insets(2)); final TextField nameInput = new TextField(); HBox.setMargin(nameInput, new Insets(0, 0, 0, 5)); HBox.setHgrow(nameInput, Priority.ALWAYS); hboxInput.getChildren().addAll(nameLabel, nameInput); final HBox hboxButtons = new HBox(); hboxButtons.setAlignment(Pos.CENTER_RIGHT); final Button ok = new Button("OK"); HBox.setMargin(ok, new Insets(6, 5, 4, 2)); final Button cancel = new Button("Cancel"); HBox.setMargin(cancel, new Insets(6, 2, 4, 5)); cancel.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent arg0) { JACPModalDialog.getInstance().hideModalDialog(); } }); ok.setDefaultButton(true); ok.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent actionEvent) { final String catName = nameInput.getText(); if (catName != null && StringUtils.hasText(catName)) { // contacts final Contact contact = new Contact(); contact.setFirstName(catName); parent.getContext().send(contact); JACPModalDialog.getInstance().hideModalDialog(); } } }); hboxButtons.getChildren().addAll(ok, cancel); box.getChildren().addAll(title, hboxInput, hboxButtons); JACPModalDialog.getInstance().showModalDialog(box); }
From source file:org.noroomattheinn.visibletesla.dialogs.VersionUpdater.java
public static boolean checkForNewerVersion(String thisVersion, Stage stage, final HostServices svcs, boolean experimentalOK) { final Versions versions = Versions.getVersionInfo(VersionsFile); if (versions == null) return false; // Missing, empty, or corrupt versions file List<Release> releases = versions.getReleases(); if (releases != null && !releases.isEmpty()) { Release lastRelease = null;/*from ww w. j ava2 s . c o m*/ for (Release cur : releases) { if (cur.getInvisible()) continue; if (cur.getExperimental() && !experimentalOK) continue; lastRelease = cur; break; } if (lastRelease == null) return false; String releaseNumber = lastRelease.getReleaseNumber(); if (Utils.compareVersions(thisVersion, releaseNumber) < 0) { VBox customPane = new VBox(); String msgText = String.format( "A newer version of VisibleTesla is available:\n" + "Version: %s, Date: %tD", releaseNumber, lastRelease.getReleaseDate()); Label msg = new Label(msgText); Hyperlink platformLink = null; final URL platformURL; final String linkText; if (SystemUtils.IS_OS_MAC) { linkText = "Download the latest Mac version"; platformURL = lastRelease.getMacURL(); } else if (SystemUtils.IS_OS_WINDOWS) { linkText = "Download the latest Windows version"; platformURL = lastRelease.getWindowsURL(); } else { linkText = "Download the latest Generic version"; platformURL = lastRelease.getReleaseURL(); } if (platformURL != null) { platformLink = new Hyperlink(linkText); platformLink.setStyle("-fx-color: blue; -fx-text-fill: blue;"); platformLink.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { svcs.showDocument(platformURL.toExternalForm()); } }); } Hyperlink rnLink = new Hyperlink("Click to view the release notes"); rnLink.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { svcs.showDocument(versions.getReleaseNotes().toExternalForm()); } }); customPane.getChildren().addAll(msg, rnLink); customPane.getChildren().add(platformLink); Dialogs.showCustomDialog(stage, customPane, "Newer Version Available", "Checking for Updates", Dialogs.DialogOptions.OK, null); return true; } } return false; }
From source file:gmailclientfx.controllers.SpamController.java
public void fetchSpam() { ObservableList<MyMessage> data = FXCollections.observableArrayList(); stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId")); stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject")); stupacFrom.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender")); stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived")); spamTable.setItems(data);/*ww w .j a v a 2 s . com*/ spamTable.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.isPrimaryButtonDown() && event.getClickCount() == 2) { MyMessage selectedMsg = spamTable.getSelectionModel().getSelectedItem(); PregledEmailaHelper.setMsg(selectedMsg); try { Parent root; FXMLLoader loader = new FXMLLoader(); loader.setLocation( getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml")); root = loader.load(); Stage stage = new Stage(); stage.setScene(new Scene(root)); PregledEmailaController pgec = loader.getController(); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { pgec.bodyWebViewEngine.load(null); System.out.println("Closing form!"); } }); stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - " + PregledEmailaHelper.getMsg().getSender()); stage.show(); } catch (IOException ex) { Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex); } } } }); try { IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(), GmailClient.getAccesToken(), true); Folder spam = null; Folder[] folders = store.getDefaultFolder().list("*"); for (Folder f : folders) { IMAPFolder imapFolder = (IMAPFolder) f; for (String att : imapFolder.getAttributes()) { if ("\\Junk".equals(att)) { spam = f; } } } spam.open(Folder.READ_WRITE); MimeMessage[] seenMessages = (MimeMessage[]) spam .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true)); for (int i = 0; i < seenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "SPAM"); data.add(msg); } MimeMessage[] unseenMessages = (MimeMessage[]) spam .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false)); for (int i = 0; i < unseenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "SPAM"); data.add(msg); } spam.close(false); store.close(); } catch (Exception ex) { Logger.getLogger(SpamController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:gov.va.isaac.gui.util.ErrorMarkerUtils.java
/** * Setup an 'EXCLAMATION' error marker on the component. Automatically displays anytime that the reasonWhyControlInvalid value * is false. Hides when the isControlCurrentlyValid is true. * @param stackPane - optional - created if necessary *//*w w w . ja va 2 s .co m*/ public static StackPane setupErrorMarker(Node initialNode, StackPane stackPane, ValidBooleanBinding isNodeCurrentlyValid) { ImageView exclamation = Images.EXCLAMATION.createImageView(); if (stackPane == null) { stackPane = new StackPane(); } exclamation.visibleProperty().bind(isNodeCurrentlyValid.not()); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(isNodeCurrentlyValid.getReasonWhyInvalid()); Tooltip.install(exclamation, tooltip); tooltip.setAutoHide(true); exclamation.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { tooltip.show(exclamation, event.getScreenX(), event.getScreenY()); } }); stackPane.setMaxWidth(Double.MAX_VALUE); stackPane.getChildren().add(initialNode); StackPane.setAlignment(initialNode, Pos.CENTER_LEFT); stackPane.getChildren().add(exclamation); StackPane.setAlignment(exclamation, Pos.CENTER_RIGHT); double insetFromRight; if (initialNode instanceof ComboBox) { insetFromRight = 30.0; } else if (initialNode instanceof ChoiceBox) { insetFromRight = 25.0; } else { insetFromRight = 5.0; } StackPane.setMargin(exclamation, new Insets(0.0, insetFromRight, 0.0, 0.0)); return stackPane; }
From source file:Main.java
@Override public void start(Stage primaryStage) { final Label markerText = new Label(); StackPane.setAlignment(markerText, Pos.TOP_CENTER); String workingDir = System.getProperty("user.dir"); final File f = new File(workingDir, "../media/omgrobots.flv"); final Media m = new Media(f.toURI().toString()); final ObservableMap<String, Duration> markers = m.getMarkers(); markers.put("Robot Finds Wall", Duration.millis(3100)); markers.put("Then Finds the Green Line", Duration.millis(5600)); markers.put("Robot Grabs Sled", Duration.millis(8000)); markers.put("And Heads for Home", Duration.millis(11500)); final MediaPlayer mp = new MediaPlayer(m); mp.setOnMarker(new EventHandler<MediaMarkerEvent>() { @Override/*from ww w. j a va 2 s.c o m*/ public void handle(final MediaMarkerEvent event) { Platform.runLater(new Runnable() { @Override public void run() { markerText.setText(event.getMarker().getKey()); } }); } }); final MediaView mv = new MediaView(mp); final StackPane root = new StackPane(); root.getChildren().addAll(mv, markerText); root.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { mp.seek(Duration.ZERO); markerText.setText(""); } }); final Scene scene = new Scene(root, 960, 540); final URL stylesheet = getClass().getResource("media.css"); scene.getStylesheets().add(stylesheet.toString()); primaryStage.setScene(scene); primaryStage.setTitle("Video Player 2"); primaryStage.show(); mp.play(); }
From source file:com.imesha.imageprocessor.controllers.MainController.java
private void setProcessButtonActionListener() { this.processButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { new Thread() { public void run() { try { // 1. Convert the image to gray scale and show in UI BufferedImage grayImage = ImageConverter.convertToGrayScale(bufferedImage); bufferedImage = grayImage; originalGrayImage = ImageUtils.deepCopy(grayImage); MainController.showImageInUI(grayImage, imageView); MainController.showMessage("Converted to Gray Scale", messageLabel); System.out.println(bufferedImage.getWidth() + "x" + bufferedImage.getHeight()); // 2. The image will be down sampled and showed in the UI. BufferedImage downSampledImage = ImageSampler.downSample(bufferedImage); bufferedImage = downSampledImage; MainController.showImageInUI(downSampledImage, previousImageView); MainController.showMessage("Down sampled", messageLabel); System.out.println(bufferedImage.getWidth() + "x" + bufferedImage.getHeight()); // 3. The down sampled image will then be up sampled BufferedImage upSampledImage = ImageSampler.upSample(bufferedImage); bufferedImage = upSampledImage; MainController.showImageInUI(upSampledImage, additionalImageView); MainController.showMessage("Up sampled", messageLabel); System.out.println(bufferedImage.getWidth() + "x" + bufferedImage.getHeight()); // 4. Calculate and show the statistics. calculateAndShowDistortion(); //Compress Images ImageCompressor compressor = CompressorFactory.getInstance() .getCompressor(CompressorFactory.RUN_LENGTH_CODING); CompressedImage compressedImage = compressor.compress(originalGrayImage); // Write the compressed image to a file. FileUtils.writeStringToFile(new File("/tmp/compress.rlc"), compressedImage.getBinaryRepresentation()); // Decompress the image BufferedImage decompressedImage = compressor.decompress(compressedImage); MainController.showImageInUI(decompressedImage, additionalImageView); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); }/*from w w w.j a va2s . c om*/ } }.start(); } }); }
From source file:gmailclientfx.controllers.PoslaneController.java
public void fetchPoslane() { ObservableList<MyMessage> data = FXCollections.observableArrayList(); stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId")); stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject")); stupacTo.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender")); stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived")); poslaneTable.setItems(data);/* ww w . ja v a2s.c o m*/ poslaneTable.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.isPrimaryButtonDown() && event.getClickCount() == 2) { MyMessage selectedMsg = poslaneTable.getSelectionModel().getSelectedItem(); PregledEmailaHelper.setMsg(selectedMsg); try { Parent root; FXMLLoader loader = new FXMLLoader(); loader.setLocation( getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml")); root = loader.load(); Stage stage = new Stage(); stage.setScene(new Scene(root)); stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - " + PregledEmailaHelper.getMsg().getSender()); stage.show(); PregledEmailaController pgec = loader.getController(); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { pgec.bodyWebViewEngine.load(null); System.out.println("Closing form!"); } }); } catch (IOException ex) { Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex); } } } }); try { IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(), GmailClient.getAccesToken(), true); Folder poslane = null; Folder[] folders = store.getDefaultFolder().list("*"); for (Folder f : folders) { IMAPFolder imapFolder = (IMAPFolder) f; for (String att : imapFolder.getAttributes()) { if ("\\Sent".equals(att)) { poslane = f; } } } poslane.open(Folder.READ_WRITE); MimeMessage[] seenMessages = (MimeMessage[]) poslane .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true)); for (int i = 0; i < seenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "SENT"); data.add(msg); } MimeMessage[] unseenMessages = (MimeMessage[]) poslane .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false)); for (int i = 0; i < unseenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "SENT"); data.add(msg); } poslane.close(false); store.close(); } catch (Exception ex) { Logger.getLogger(PoslaneController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:de.chaosfisch.uploader.gui.renderer.TagTextArea.java
private void initPicker(final WebView webView) { webView.getEngine().loadContent(getInlineHtml()); webView.setContextMenuEnabled(false); webView.getEngine().setOnAlert(new EventHandler<WebEvent<String>>() { @Override/* w w w . j a v a 2 s . c om*/ public void handle(final WebEvent<String> event) { tags.set(event.getData()); } }); getChildren().add(webView); }
From source file:ch.unibas.fittingwizard.presentation.addmolecule.CoordinatesPage.java
@Override protected void fillButtonBar() { Button prevButton = ButtonFactory.createButtonBarButton("Previous", new EventHandler<ActionEvent>() { @Override/* w w w . java 2s . co m*/ public void handle(ActionEvent actionEvent) { logger.info("Going back to molecule list."); navigateTo(MoleculeListPage.class); } }); addButtonToButtonBar(prevButton); Button nextButton = ButtonFactory.createButtonBarButton("Next", new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { logger.info("Going to input parameters."); MultipoleGaussParameterDto inputDto = new MultipoleGaussParameterDto(xyzFile); navigateTo(MultipoleGaussParameterPage.class, inputDto); } }); addButtonToButtonBar(nextButton); }
From source file:gmailclientfx.controllers.ObrisaneController.java
public void fetchObrisane() { ObservableList<MyMessage> data = FXCollections.observableArrayList(); stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId")); stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject")); stupacFrom.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender")); stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived")); obrisaneTable.setItems(data);//from w w w .j a v a2 s .co m obrisaneTable.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.isPrimaryButtonDown() && event.getClickCount() == 2) { MyMessage selectedMsg = obrisaneTable.getSelectionModel().getSelectedItem(); PregledEmailaHelper.setMsg(selectedMsg); try { Parent root; FXMLLoader loader = new FXMLLoader(); loader.setLocation( getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml")); root = loader.load(); Stage stage = new Stage(); stage.setScene(new Scene(root)); stage.show(); PregledEmailaController pgec = loader.getController(); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { pgec.bodyWebViewEngine.load(null); System.out.println("Closing form!"); } }); stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - " + PregledEmailaHelper.getMsg().getSender()); } catch (IOException ex) { Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex); } } } }); try { IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(), GmailClient.getAccesToken(), true); Folder obrisane = null; Folder[] folders = store.getDefaultFolder().list("*"); for (Folder f : folders) { IMAPFolder imapFolder = (IMAPFolder) f; for (String att : imapFolder.getAttributes()) { if ("\\Trash".equals(att)) { obrisane = f; } } } obrisane.open(Folder.READ_WRITE); MimeMessage[] seenMessages = (MimeMessage[]) obrisane .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true)); for (int i = 0; i < seenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "DELETED"); data.add(msg); } MimeMessage[] unseenMessages = (MimeMessage[]) obrisane .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false)); for (int i = 0; i < unseenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "DELETED"); data.add(msg); } obrisane.close(false); store.close(); } catch (Exception ex) { Logger.getLogger(ObrisaneController.class.getName()).log(Level.SEVERE, null, ex); } }