Java Code Examples for javafx.stage.Popup#setAutoHide()
The following examples show how to use
javafx.stage.Popup#setAutoHide() .
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: FxmlControl.java From MyBox with Apache License 2.0 | 6 votes |
public static void popText(String text, String color, String size, Stage stage) { try { Popup popup = new Popup(); popup.setAutoHide(true); popup.setAutoFix(true); Label popupLabel = new Label(text); popupLabel.setStyle("-fx-background-color:black;" + " -fx-text-fill: " + color + ";" + " -fx-font-size: " + size + ";" + " -fx-padding: 10px;" + " -fx-background-radius: 6;"); popup.getContent().add(popupLabel); popup.show(stage); } catch (Exception e) { } }
Example 2
Source File: PopupSelectbox.java From logbook-kai with MIT License | 6 votes |
public void show(Node anchorNode) { PopupSelectboxContainer<T> container = new PopupSelectboxContainer<>(); container.setItems(this.items.get()); container.setCellFactory(this.cellFactory.get()); container.setSelectedItem(this.selectedItem); container.getStylesheets().addAll(this.styleSheets); container.headerContents().addAll(this.headerContents); container.init(); Popup stage = new Popup(); stage.getContent().addAll(container); stage.setAutoHide(true); stage.setAnchorLocation(PopupWindow.AnchorLocation.CONTENT_TOP_LEFT); Bounds screen = anchorNode.localToScreen(anchorNode.getLayoutBounds()); stage.show(anchorNode.getScene().getWindow(), screen.getMinX(), screen.getMaxY()); }
Example 3
Source File: LongTextField.java From milkman with MIT License | 5 votes |
public LongTextField() { popup = new Popup(); popup.setAutoHide(true); popup.setHideOnEscape(true); popup.setConsumeAutoHidingEvents(false); content = new JFXTextArea(); content.setBackground(new Background(new BackgroundFill(Color.rgb(255,255,255), null, null))); content.setPrefHeight(60); content.setWrapText(false); popup.getContent().add(new VBox(content)); setupListener(); }
Example 4
Source File: GenerateCodeDialog.java From tcMenu with Apache License 2.0 | 5 votes |
private void selectPlugin(List<CodePluginItem> pluginItems, String changeWhat, Consumer<CodePluginItem> eventHandler) { Popup popup = new Popup(); List<UICodePluginItem> listOfComponents = pluginItems.stream() .map(display -> { var it = new UICodePluginItem(manager, display, SELECT, item -> { popup.hide(); eventHandler.accept(item); }); it.setId("sel-" + display.getId()); return it; }) .collect(Collectors.toList()); VBox vbox = new VBox(5); addTitleLabel(vbox, "Select the " + changeWhat + " to use:"); vbox.getChildren().addAll(listOfComponents); vbox.setPrefSize(700, 600); BorderPane pane = new BorderPane(); pane.setCenter(vbox); vbox.getStyleClass().add("popupWindow"); popup.getContent().add(pane); popup.setAutoHide(true); popup.setOnAutoHide(event -> popup.hide()); popup.setHideOnEscape(true); popup.show(dialogStage); }
Example 5
Source File: SearchableTreeView.java From pmd-designer with BSD 2-Clause "Simplified" License | 4 votes |
/** * Textfield for the search query. */ private void popSearchField() { TextField textField = new TextField(); textField.setPrefWidth(150); textField.setPromptText("Search tree"); ControlUtil.makeTextFieldShowPromptEvenIfFocused(textField); Label label = new Label(); label.getStyleClass().addAll("hint-label"); label.setTooltip(new Tooltip("Go to next result with F3")); StackPane pane = new StackPane(); pane.getStyleClass().addAll("search-popup"); pane.getStylesheets().addAll(DesignerUtil.getCss("designer").toString()); StackPane.setAlignment(textField, Pos.TOP_RIGHT); StackPane.setAlignment(label, Pos.BOTTOM_RIGHT); pane.getChildren().addAll(textField, label); Val<String> query = Val.wrap(textField.textProperty()) .filter(StringUtils::isNotBlank).map(String::trim) .filter(it -> it.length() >= MIN_QUERY_LENGTH); Var<Integer> numResults = Var.newSimpleVar(0); Subscription subscription = bindSearchQuery(query.conditionOnShowing(pane), numResults, textField); label.textProperty().bind( numResults.map(n -> n == 0 ? "no match" : n == 1 ? "1 match" : n + " matches") ); label.visibleProperty().bind(query.map(Objects::nonNull)); Popup popup = new Popup(); popup.getContent().addAll(pane); popup.setAutoHide(true); popup.setHideOnEscape(true); Bounds bounds = localToScreen(getBoundsInLocal()); popup.show(this, bounds.getMaxX() - textField.getPrefWidth() - 1, bounds.getMinY()); popup.setOnHidden(e -> { openSearchField = null; subscription.unsubscribe(); }); // release resources // Hide popup when ENTER or ESCAPE is pressed EventStreams.eventsOf(popup, KeyEvent.KEY_RELEASED) .filter(it -> it.getCode() == KeyCode.ENTER || it.getCode() == KeyCode.ESCAPE) .subscribeForOne(e -> { popup.hide(); e.consume(); }); textField.requestFocus(); openSearchField = textField; }
Example 6
Source File: ImagesBrowserController.java From MyBox with Apache License 2.0 | 4 votes |
private void makeImagePopup(VBox imageBox, ImageInformation imageInfo, ImageView iView) { try { File file = imageInfo.getImageFileInformation().getFile(); final Image iImage = imageInfo.getImage(); imagePop = new Popup(); imagePop.setWidth(popSize + 40); imagePop.setHeight(popSize + 40); imagePop.setAutoHide(true); VBox vbox = new VBox(); VBox.setVgrow(vbox, Priority.ALWAYS); HBox.setHgrow(vbox, Priority.ALWAYS); vbox.setMaxWidth(Double.MAX_VALUE); vbox.setMaxHeight(Double.MAX_VALUE); vbox.setStyle("-fx-background-color: white;"); imagePop.getContent().add(vbox); popView = new ImageView(); popView.setImage(iImage); if (iImage.getWidth() > iImage.getHeight()) { popView.setFitWidth(popSize); } else { popView.setFitHeight(popSize); } popView.setPreserveRatio(true); vbox.getChildren().add(popView); popText = new Text(); popText.setStyle("-fx-font-size: 1.0em;"); vbox.getChildren().add(popText); vbox.setPadding(new Insets(15, 15, 15, 15)); String info = imageInfo.getFileName() + "\n" + AppVariables.message("Format") + ":" + imageInfo.getImageFormat() + " " + AppVariables.message("ModifyTime") + ":" + DateTools.datetimeToString(file.lastModified()) + "\n" + AppVariables.message("Size") + ":" + FileTools.showFileSize(file.length()) + " " + AppVariables.message("Pixels") + ":" + imageInfo.getWidth() + "x" + imageInfo.getHeight() + "\n" + AppVariables.message("LoadedSize") + ":" + (int) iView.getImage().getWidth() + "x" + (int) iView.getImage().getHeight() + " " + AppVariables.message("DisplayedSize") + ":" + (int) iView.getFitWidth() + "x" + (int) iView.getFitHeight(); popText.setText(info); popText.setWrappingWidth(popSize); Bounds bounds = imageBox.localToScreen(imageBox.getBoundsInLocal()); imagePop.show(imageBox, bounds.getMinX() + bounds.getWidth() / 2, bounds.getMinY()); } catch (Exception e) { logger.debug(e.toString()); } }
Example 7
Source File: GameElimniationController.java From MyBox with Apache License 2.0 | 4 votes |
protected void afterElimination(int imageIndex, int size) { try { if (isSettingValues || !countScore || !countedChesses.contains(imageIndex)) { return; } int add = scoreRulers.get(size); totalScore += add; long cost = new Date().getTime() - startTime.getTime(); scoreLabel.setText(message("Score") + ": " + totalScore + " " + message("Cost") + ": " + DateTools.showSeconds(cost / 1000)); if (add > 0) { if (scoreCheck.isSelected()) { Label popupLabel = new Label("+" + add); popupLabel.setStyle("-fx-background-color:black;" + " -fx-text-fill: gold;" + " -fx-font-size: 3em;" + " -fx-padding: 10px;" + " -fx-background-radius: 10;"); final Popup scorePopup = new Popup(); scorePopup.setAutoFix(true); scorePopup.setAutoHide(true); scorePopup.getContent().add(popupLabel); FxmlControl.locateUp(scoreLabel, scorePopup); Timer stimer = new Timer(); stimer.schedule(new TimerTask() { @Override public void run() { Platform.runLater(new Runnable() { @Override public void run() { scorePopup.hide(); } }); } }, 1000); } if (guaiRadio.isSelected()) { FxmlControl.GuaiAO(); } else if (benRadio.isSelected()) { FxmlControl.BenWu(); } else if (guaiBenRadio.isSelected()) { if (size == 3) { FxmlControl.BenWu(); } else { FxmlControl.GuaiAO(); } } else if (customizedSoundRadio.isSelected() && soundFile != null && soundFile.exists()) { FxmlControl.mp3(soundFile); } } } catch (Exception e) { } }
Example 8
Source File: PersonTypeCellFactory.java From examples-javafx-repos1 with Apache License 2.0 | 4 votes |
@Override public TableCell<Person, String> call(TableColumn<Person, String> param) { return new ComboBoxTableCell<Person, String>(new DefaultStringConverter()) { { ContextMenu cm = new ContextMenu(); MenuItem deletePersonsMenuItem = new MenuItem("Delete"); deletePersonsMenuItem.setOnAction( PersonTypeCellFactory.this.deletePersonsHandler ); cm.getItems().add(deletePersonsMenuItem); this.setContextMenu(cm); this.getItems().addAll( "Friend", "Co-worker", "Other" ); this.setEditable(true); } @Override public void updateItem(String arg0, boolean empty) { super.updateItem(arg0, empty); if( !empty ) { this.setText( arg0 ); } else { this.setText( null ); // clear from recycled obj } } @SuppressWarnings("unchecked") @Override public void commitEdit(String newValue) { super.commitEdit(newValue); TableRow<Person> row = this.getTableRow(); Person p = row.getItem(); String msg = p.validate(); if( logger.isLoggable(Level.FINE) ) { logger.fine("[COMMIT EDIT] validate=" + msg); } if( msg == null || msg.isEmpty() ) { if( logger.isLoggable(Level.FINE) ) { logger.fine("[COMMIT EDIT] validation passed"); } Task<Void> task = new Task<Void>() { @Override protected Void call() { dao.updatePerson(p); // updates AR too return null; } }; new Thread(task).start(); } else { System.out.println("layoutBounds=" + this.getLayoutBounds()); System.out.println("boundsInLocal=" + this.getBoundsInLocal()); System.out.println("boundsInParent=" + this.getBoundsInParent()); System.out.println("boundsInParent (Scene)=" + this.localToScene(this.getBoundsInParent())); System.out.println("boundsInParent (Screen)=" + this.localToScreen(this.getBoundsInParent())); System.out.println("row layoutBounds=" + row.getLayoutBounds()); System.out.println("row boundsInLocal=" + row.getBoundsInLocal()); System.out.println("row boundsInParent=" + row.getBoundsInParent()); System.out.println("row boundsInParent (Scene)=" + row.localToScene(this.getBoundsInParent())); System.out.println("row boundsInParent (Screen)=" + row.localToScreen(this.getBoundsInParent())); VBox vbox = new VBox(); vbox.setPadding(new Insets(10.0d)); vbox.setStyle("-fx-background-color: white; -fx-border-color: red"); vbox.getChildren().add( new Label(msg)); //vbox.setEffect(new DropShadow()); Popup popup = new Popup(); popup.getContent().add( vbox ); popup.setAutoHide(true); popup.setOnShown((evt) -> { System.out.println("vbox layoutBounds=" + vbox.getLayoutBounds()); System.out.println("vbox boundsInLocal=" + vbox.getBoundsInLocal()); System.out.println("vbox boundsInParent=" + vbox.getBoundsInParent()); System.out.println("vbox boundsInParent (Scene)=" + vbox.localToScene(this.getBoundsInParent())); System.out.println("vbox boundsInParent (Screen)=" + vbox.localToScreen(this.getBoundsInParent())); }); popup.show( row, row.localToScreen(row.getBoundsInParent()).getMinX(), row.localToScreen(row.getBoundsInParent()).getMaxY()); } } }; }
Example 9
Source File: PersonsCellFactory.java From examples-javafx-repos1 with Apache License 2.0 | 4 votes |
@Override public TableCell<Person, String> call(TableColumn<Person, String> param) { return new TextFieldTableCell<Person, String>(new DefaultStringConverter()) { { ContextMenu cm = new ContextMenu(); MenuItem deletePersonsMenuItem = new MenuItem("Delete"); deletePersonsMenuItem.setOnAction( PersonsCellFactory.this.deletePersonsHandler ); cm.getItems().add(deletePersonsMenuItem); this.setContextMenu(cm); } @Override public void updateItem(String arg0, boolean empty) { super.updateItem(arg0, empty); if( !empty ) { this.setText( arg0 ); } else { this.setText( null ); // clear from recycled obj } } @SuppressWarnings("unchecked") @Override public void commitEdit(String newValue) { super.commitEdit(newValue); TableRow<Person> row = this.getTableRow(); Person p = row.getItem(); String msg = p.validate(); if( logger.isLoggable(Level.FINE) ) { logger.fine("[COMMIT EDIT] validate=" + msg); } if( msg == null || msg.isEmpty() ) { if( logger.isLoggable(Level.FINE) ) { logger.fine("[COMMIT EDIT] validation passed"); } Task<Void> task = new Task<Void>() { @Override protected Void call() { dao.updatePerson(p); // updates AR too return null; } }; new Thread(task).start(); } else { System.out.println("layoutBounds=" + this.getLayoutBounds()); System.out.println("boundsInLocal=" + this.getBoundsInLocal()); System.out.println("boundsInParent=" + this.getBoundsInParent()); System.out.println("boundsInParent (Scene)=" + this.localToScene(this.getBoundsInParent())); System.out.println("boundsInParent (Screen)=" + this.localToScreen(this.getBoundsInParent())); System.out.println("row layoutBounds=" + row.getLayoutBounds()); System.out.println("row boundsInLocal=" + row.getBoundsInLocal()); System.out.println("row boundsInParent=" + row.getBoundsInParent()); System.out.println("row boundsInParent (Scene)=" + row.localToScene(this.getBoundsInParent())); System.out.println("row boundsInParent (Screen)=" + row.localToScreen(this.getBoundsInParent())); VBox vbox = new VBox(); vbox.setPadding(new Insets(10.0d)); vbox.setStyle("-fx-background-color: white; -fx-border-color: red"); vbox.getChildren().add( new Label(msg)); //vbox.setEffect(new DropShadow()); Popup popup = new Popup(); popup.getContent().add( vbox ); popup.setAutoHide(true); popup.setOnShown((evt) -> { System.out.println("vbox layoutBounds=" + vbox.getLayoutBounds()); System.out.println("vbox boundsInLocal=" + vbox.getBoundsInLocal()); System.out.println("vbox boundsInParent=" + vbox.getBoundsInParent()); System.out.println("vbox boundsInParent (Scene)=" + vbox.localToScene(this.getBoundsInParent())); System.out.println("vbox boundsInParent (Screen)=" + vbox.localToScreen(this.getBoundsInParent())); }); popup.show( row, row.localToScreen(row.getBoundsInParent()).getMinX(), row.localToScreen(row.getBoundsInParent()).getMaxY()); } } }; }