List of usage examples for javafx.stage Modality APPLICATION_MODAL
Modality APPLICATION_MODAL
To view the source code for javafx.stage Modality APPLICATION_MODAL.
Click Source Link
From source file:jlotoprint.MainViewController.java
public static void showExceptionAlert(String message, String details) { Alert alert = new Alert(Alert.AlertType.ERROR, message, ButtonType.OK); alert.initModality(Modality.APPLICATION_MODAL); alert.initOwner(JLotoPrint.stage.getScene().getWindow()); TextArea textArea = new TextArea(details); textArea.setEditable(false);/*from www.j a v a 2s. c o m*/ textArea.setWrapText(true); GridPane grid = new GridPane(); grid.setPadding(new Insets(10, 10, 0, 10)); grid.add(textArea, 0, 0); //set content alert.getDialogPane().setExpandableContent(grid); alert.showAndWait(); }
From source file:ijfx.ui.test.DummyCategories.java
@Override public void run() { ExplorableList output = new ExplorableList(); ExplorableList output2 = new ExplorableList(); ExplorableList output3 = new ExplorableList(); for (int i = 0; i != 10; i++) { MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false)); MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false)); MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false)); MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble()); MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble()); Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); output.add(explorable);//from ww w.j ava 2s. c o m } for (int i = 0; i != 5; i++) { MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false)); MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false)); MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false)); MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble()); MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble()); Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); output2.add(explorable); } for (int i = 0; i != 3; i++) { MetaData name = MetaData.create(MetaData.NAME, RandomStringUtils.random(3, true, false)); MetaData m1 = MetaData.create("Random strings 1", RandomStringUtils.random(5, true, false)); MetaData m2 = MetaData.create("Random strings 2", RandomStringUtils.random(3, true, false)); MetaData m3 = MetaData.create("Random double 1", new Random().nextDouble()); MetaData m4 = MetaData.create("Random double 2", new Random().nextDouble()); Explorable explorable = new MetaDataSetExplorerWrapper(name, m1, m2, m3, m4); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); explorable.addTag(Tag.create(RandomStringUtils.random(3, true, false))); output3.add(explorable); } Pane pane = ctrl.addCategory("Cat 1").setElements("Cat 1", output) //set the element that the first line will contain .addCategory("Cat 2").setElements("Cat 2", output2).setMaxItemPerCategory(8).generate(); // returns the Pane that contains the view ctrl.setElements("Cat 2", output3); ctrl.update(); // updates the pane returned previously Platform.runLater(() -> { Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); Scene scene = new Scene(pane, 550, 600); ////////CSS part/////// URL cssURL = getClass().getResource("/ijfx/ui/flatterfx.css"); if (cssURL != null) { scene.getStylesheets().add(cssURL.toExternalForm()); } stage.setScene(scene); stage.show(); }); }
From source file:org.ado.musicdroid.view.AppPresenter.java
public void settings() { final Stage stage = new Stage(); final SettingsView settingsView = new SettingsView(); final SettingsPresenter presenter = (SettingsPresenter) settingsView.getPresenter(); presenter.setStage(stage, this::loadAlbumList); stage.initModality(Modality.APPLICATION_MODAL); stage.setScene(new Scene(settingsView.getView())); stage.setTitle("Settings"); stage.show();// www. ja v a 2 s .c o m }
From source file:ExcelFx.FXMLDocumentController.java
@FXML private void Open(ActionEvent event) throws NullPointerException, IOException { System.out.println("-----------------------------------------------------------"); System.out.println("Pressed open Button "); File universityFile = new File("university.json"); File collegeFile = new File("college.json"); System.out.println("University File emty is " + String.valueOf(universityFile.length() == 0)); System.out.println("College File emty is " + String.valueOf(collegeFile.length() == 0)); //File codesFile = new File("codes.json"); if ((universityFile.exists()) && (collegeFile.exists()) /*&& (codesFile.exists())*/) { try {/*from w w w. ja v a2 s . c om*/ this.universityJson.jsonRead("university.json"); this.collegeJson.jsonRead("college.json"); //this.codesJson.jsonRead("codes.json"); this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/); } catch (IOException | ParseException ex) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle(""); alert.setHeaderText(" ? ? "); alert.setContentText(ex.toString()); alert.showAndWait(); Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex); } } else { try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FileOpenFXML.fxml")); this.fileOpenParent = (Parent) fxmlLoader.load(); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.initStyle(StageStyle.DECORATED); stage.setTitle(" "); stage.setScene(new Scene(this.fileOpenParent)); stage.showAndWait(); } catch (Exception e) { System.err.println(e); } this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/); } FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("InitalData.fxml")); Parent root1 = (Parent) fxmlLoader.load(); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.initStyle(StageStyle.DECORATED); stage.setTitle(" "); stage.setScene(new Scene(root1)); stage.showAndWait(); setProgressBar(-1.); Task task = new Task<Void>() { @Override protected Void call() throws Exception { initaldata = (JsonWrite) root1.getUserData(); System.out.println("Inital Data empty is " + initaldata.isEmpty()); initaldata.setPage(String.valueOf(Integer.parseInt(initaldata.getPage()) - 1)); Parser parser = new Parser(); list = parser.parseInitalData(initaldata.getPatch(), Integer.parseInt(initaldata.getPage())); //System.out.println(list.size()); Sort sort = new Sort(list, jsonXLSXData, initaldata.getYStart(), initaldata.getYEnd()); HashMap<String, HashMap<String, ArrayList<String>>> hm = sort .professionsGrouping(initaldata.getYStart(), initaldata.getYEnd()); sortProf = sort.addWay(hm); return null; } }; mainProcessing(task); System.out.println("button open finished"); System.out.println("-----------------------------------------------------------"); }
From source file:org.ado.musicdroid.view.AppPresenter.java
public void about() { final Stage stage = new Stage(); final AboutView aboutView = new AboutView(); final AboutPresenter presenter = (AboutPresenter) aboutView.getPresenter(); presenter.setStage(stage);/*w w w . j av a2s . co m*/ stage.initModality(Modality.APPLICATION_MODAL); stage.setScene(new Scene(aboutView.getView())); stage.setTitle("About"); stage.show(); }
From source file:com.panemu.tiwulfx.control.LookupFieldController.java
/** * Show lookup dialog./* ww w . j av a 2 s. c o m*/ * * @param stage parent * @param initialValue this value will be returned if user clik the close * button instead of double clicking a row or click Select button * @param propertyName propertyName corresponds to searchCriteria * @param searchCriteria searchCriteria (nullable) * @return selected object or the initialValue */ public T show(final Window stage, T initialValue, String propertyName, String searchCriteria) { if (dialogStage == null) { PropertyDescriptor[] props = PropertyUtils.getPropertyDescriptors(recordClass); lookupWindow = new LookupWindow(); for (String clm : getColumns()) { for (PropertyDescriptor prop : props) { if (prop.getName().equals(clm)) { Class type = prop.getPropertyType(); if (type.equals(Boolean.class)) { lookupWindow.table.addColumn(new CheckBoxColumn<T>(clm)); } else if (type.equals(String.class)) { lookupWindow.table.addColumn(new TextColumn<T>(clm)); } else if (type.equals(Date.class)) { lookupWindow.table.addColumn(new LocalDateColumn<T>(clm)); } else if (Number.class.isAssignableFrom(type)) { if (Long.class.isAssignableFrom(type)) { lookupWindow.table.addColumn(new NumberColumn<T, Long>(clm, type)); } else { lookupWindow.table.addColumn(new NumberColumn<T, Double>(clm, type)); } } else { TableColumn column = new TableColumn(); column.setCellValueFactory(new PropertyValueFactory(clm)); lookupWindow.table.addColumn(column); } break; } } } dialogStage = new Stage(); if (stage instanceof Stage) { dialogStage.initOwner(stage); dialogStage.initModality(Modality.WINDOW_MODAL); } else { dialogStage.initOwner(null); dialogStage.initModality(Modality.APPLICATION_MODAL); } dialogStage.initStyle(StageStyle.UTILITY); dialogStage.setResizable(true); dialogStage.setScene(new Scene(lookupWindow)); dialogStage.getIcons().add(new Image( LookupFieldController.class.getResourceAsStream("/com/panemu/tiwulfx/res/image/lookup.png"))); dialogStage.setTitle(getWindowTitle()); dialogStage.getScene().getStylesheets() .add(getClass().getResource("/com/panemu/tiwulfx/res/tiwulfx.css").toExternalForm()); initCallback(lookupWindow, lookupWindow.table); } for (TableColumn column : lookupWindow.table.getTableView().getColumns()) { if (column instanceof BaseColumn && ((BaseColumn) column).getPropertyName().equals(propertyName)) { if (searchCriteria != null && !searchCriteria.isEmpty()) { TableCriteria tc = new TableCriteria(propertyName, TableCriteria.Operator.ilike_anywhere, searchCriteria); ((BaseColumn) column).setTableCriteria(tc); } else { ((BaseColumn) column).setTableCriteria(null); } break; } } selectedValue = initialValue; beforeShowCallback(lookupWindow.table); lookupWindow.table.reloadFirstPage(); if (stage != null) { /** * Since we support multiple monitors, ensure that the stage is * located in the center of parent stage. But we don't know the * dimension of the stage for the calculation, so we defer the * relocation after the stage is actually displayed. */ Runnable runnable = new Runnable() { public void run() { dialogStage.setX(stage.getX() + stage.getWidth() / 2 - dialogStage.getWidth() / 2); dialogStage.setY(stage.getY() + stage.getHeight() / 2 - dialogStage.getHeight() / 2); //set the opacity back to fully opaque dialogStage.setOpacity(1); } }; Platform.runLater(runnable); //set the opacity to 0 to minimize flicker effect dialogStage.setOpacity(0); } dialogStage.showAndWait(); return selectedValue; }
From source file:de.perdoctus.ebikeconnect.gui.ActivitiesOverviewController.java
@FXML public void initialize() { logger.info("Init!"); NUMBER_FORMAT.setMaximumFractionDigits(2); webEngine = webView.getEngine();//from ww w . ja v a 2 s . c o m webEngine.load(getClass().getResource("/html/googleMap.html").toExternalForm()); // Activity Headers activityDaysHeaderService.setOnSucceeded(event -> { activitiesTable.setItems(FXCollections.observableArrayList(activityDaysHeaderService.getValue())); activitiesTable.getSortOrder().add(tcDate); tcDate.setSortable(true); }); activityDaysHeaderService.setOnFailed( event -> logger.error("Failed to obtain ActivityList!", activityDaysHeaderService.getException())); final ProgressDialog activityHeadersProgressDialog = new ProgressDialog(activityDaysHeaderService); activityHeadersProgressDialog.initModality(Modality.APPLICATION_MODAL); // Activity Details activityDetailsGroupService.setOnSucceeded( event -> this.currentActivityDetailsGroup.setValue(activityDetailsGroupService.getValue())); activityDetailsGroupService.setOnFailed(event -> logger.error("Failed to obtain ActivityDetails!", activityDaysHeaderService.getException())); final ProgressDialog activityDetailsProgressDialog = new ProgressDialog(activityDetailsGroupService); activityDetailsProgressDialog.initModality(Modality.APPLICATION_MODAL); // Gpx Export gpxExportService.setOnSucceeded(event -> gpxExportFinished()); gpxExportService .setOnFailed(event -> handleError("Failed to generate GPX File", gpxExportService.getException())); tcxExportService.setOnSucceeded(event -> gpxExportFinished()); tcxExportService .setOnFailed(event -> handleError("Failed to generate TCX File", tcxExportService.getException())); // ActivityTable tcDate.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDate())); tcDate.setCellFactory(param -> new LocalDateCellFactory()); tcDate.setSortType(TableColumn.SortType.DESCENDING); tcDistance.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDistance() / 1000)); tcDistance.setCellFactory(param -> new NumberCellFactory(1, "km")); tcDuration.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDrivingTime())); tcDuration.setCellFactory(param -> new DurationCellFactory()); activitiesTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); activitiesTable.getSelectionModel().getSelectedItems() .addListener((ListChangeListener<ActivityHeaderGroup>) c -> { while (c.next()) { if (c.wasRemoved()) { for (ActivityHeaderGroup activityHeaderGroup : c.getRemoved()) { lstSegments.getItems().removeAll(activityHeaderGroup.getActivityHeaders()); } } if (c.wasAdded()) { for (ActivityHeaderGroup activityHeaderGroup : c.getAddedSubList()) { if (activityHeaderGroup != null) { // WTF? Why can this be null!? lstSegments.getItems().addAll(activityHeaderGroup.getActivityHeaders()); } } } } lstSegments.getItems().sort((o1, o2) -> o1.getStartTime().isAfter(o2.getStartTime()) ? 1 : 0); }); activitiesTable.setOnMouseClicked(event -> { if (event.getClickCount() == 2) { lstSegments.getCheckModel().checkAll(); openSelectedSections(); } }); // Segment List lstSegments .setCellFactory(listView -> new CheckBoxListCell<>(item -> lstSegments.getItemBooleanProperty(item), new StringConverter<ActivityHeader>() { @Override public ActivityHeader fromString(String arg0) { return null; } @Override public String toString(ActivityHeader activityHeader) { final String startTime = activityHeader.getStartTime().format(DATE_TIME_FORMATTER); final String endTime = activityHeader.getEndTime().format(TIME_FORMATTER); final double distance = activityHeader.getDistance() / 1000; return startTime + " - " + endTime + " (" + NUMBER_FORMAT.format(distance) + " km)"; } })); // -- Chart chartRangeSlider.setLowValue(0); chartRangeSlider.setHighValue(chartRangeSlider.getMax()); xAxis.setAutoRanging(false); xAxis.lowerBoundProperty().bind(chartRangeSlider.lowValueProperty()); xAxis.upperBoundProperty().bind(chartRangeSlider.highValueProperty()); xAxis.tickUnitProperty().bind( chartRangeSlider.highValueProperty().subtract(chartRangeSlider.lowValueProperty()).divide(20)); xAxis.setTickLabelFormatter(new StringConverter<Number>() { @Override public String toString(Number object) { final Duration duration = Duration.of(object.intValue(), ChronoUnit.SECONDS); return String.valueOf(DurationFormatter.formatHhMmSs(duration)); } @Override public Number fromString(String string) { return null; } }); chart.getChart().setOnScroll(event -> { final double scrollAmount = event.getDeltaY(); chartRangeSlider.setLowValue(chartRangeSlider.getLowValue() + scrollAmount); chartRangeSlider.setHighValue(chartRangeSlider.getHighValue() - scrollAmount); }); xAxis.setOnMouseMoved(event -> { if (getCurrentActivityDetailsGroup() == null) { return; } final Number valueForDisplay = xAxis.getValueForDisplay(event.getX()); final List<Coordinate> trackpoints = getCurrentActivityDetailsGroup().getJoinedTrackpoints(); final int index = valueForDisplay.intValue(); if (index >= 0 && index < trackpoints.size()) { final Coordinate coordinate = trackpoints.get(index); if (coordinate.isValid()) { final LatLng latLng = new LatLng(coordinate); try { webEngine.executeScript( "updateMarkerPosition(" + objectMapper.writeValueAsString(latLng) + ");"); } catch (JsonProcessingException e) { e.printStackTrace(); //TODO clean up ugly code!!!!-------------- } } } }); // -- Current ActivityDetails this.currentActivityDetailsGroup.addListener((observable, oldValue, newValue) -> { if (newValue != null) { activityGroupChanged(newValue); } }); }
From source file:org.sleuthkit.autopsy.timeline.ShowInTimelineDialog.java
/** * Common Private Constructor/*from www . ja v a 2 s. c o m*/ * * @param controller The controller for this Dialog. * @param eventIDS A List of eventIDs to present to the user to choose * from. */ @NbBundle.Messages({ "ShowInTimelineDialog.amountValidator.message=The entered amount must only contain digits." }) private ShowInTimelineDialog(TimeLineController controller, List<Long> eventIDS) { this.controller = controller; //load dialog content fxml final String name = "nbres:/" + StringUtils.replace(ShowInTimelineDialog.class.getPackage().getName(), ".", "/") + "/ShowInTimelineDialog.fxml"; // NON-NLS try { FXMLLoader fxmlLoader = new FXMLLoader(new URL(name)); fxmlLoader.setRoot(contentRoot); fxmlLoader.setController(this); fxmlLoader.load(); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Unable to load FXML, node initialization may not be complete.", ex); //NON-NLS } //assert that fxml loading happened correctly assert eventTable != null : "fx:id=\"eventTable\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert typeColumn != null : "fx:id=\"typeColumn\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert dateTimeColumn != null : "fx:id=\"dateTimeColumn\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert amountSpinner != null : "fx:id=\"amountsSpinner\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert unitComboBox != null : "fx:id=\"unitChoiceBox\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; //validat that spinner has a integer in the text field. validationSupport.registerValidator(amountSpinner.getEditor(), false, Validator.createPredicateValidator( NumberUtils::isDigits, Bundle.ShowInTimelineDialog_amountValidator_message())); //configure dialog properties PromptDialogManager.setDialogIcons(this); initModality(Modality.APPLICATION_MODAL); //add scenegraph loaded from fxml to this dialog. DialogPane dialogPane = getDialogPane(); dialogPane.setContent(contentRoot); //add buttons to dialog dialogPane.getButtonTypes().setAll(SHOW, ButtonType.CANCEL); ///configure dialog controls amountSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 1000)); amountSpinner.getValueFactory().setConverter(new IntegerStringConverter() { /** * Convert the String to an Integer using Integer.valueOf, but if * that throws a NumberFormatException, reset the spinner to the * last valid value. * * @param string The String to convert * * @return The Integer value of string. */ @Override public Integer fromString(String string) { try { return super.fromString(string); } catch (NumberFormatException ex) { return amountSpinner.getValue(); } } }); unitComboBox.setButtonCell(new ChronoFieldListCell()); unitComboBox.setCellFactory(comboBox -> new ChronoFieldListCell()); unitComboBox.getItems().setAll(SCROLL_BY_UNITS); unitComboBox.getSelectionModel().select(ChronoField.MINUTE_OF_HOUR); typeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getEventType())); typeColumn.setCellFactory(param -> new TypeTableCell<>()); dateTimeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getStartMillis())); dateTimeColumn.setCellFactory(param -> new DateTimeTableCell<>()); //add events to table eventTable.getItems().setAll( eventIDS.stream().map(controller.getEventsModel()::getEventById).collect(Collectors.toSet())); eventTable.setPrefHeight(Math.min(200, 24 * eventTable.getItems().size() + 28)); }
From source file:de.micromata.mgc.javafx.ControllerService.java
public <M, C extends AbstractModelController<M>> C loadAsDialog(AbstractMainWindow<?> mainWindow, Class<C> controllerClass, String dialogTitle) { Pair<Pane, C> pair = loadControllerControl(controllerClass, Pane.class, mainWindow); Stage stage = new Stage(); stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, e -> { stage.hide();/* ww w . j av a2s . c o m*/ e.consume(); }); Pane root = pair.getFirst(); C controller = pair.getSecond(); Scene s = new Scene(root);//, AbstractConfigDialog.PREF_WIDTH, AbstractConfigDialog.PREF_HEIGHT controller.setParent(root); controller.setScene(s); controller.setStage(stage); stage.setScene(s); stage.initModality(Modality.APPLICATION_MODAL); //stage.setResizable(false); stage.setTitle(dialogTitle); return controller; }
From source file:com.helegris.szorengeteg.ui.forms.TopicFormView.java
private void bulkAddWords() { Stage stage = new Stage(); BulkAddWordsView view = new BulkAddWordsView(); stage.setScene(new SceneStyler().createScene(view, SceneStyler.Style.TOPIC_LIST)); stage.setTitle(Messages.msg("form.bulk_add_something", Messages.msg("form.word_and_description"))); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(getScene().getWindow()); stage.showAndWait();//from w w w . ja v a2s.co m loadRows(view.getCards()); }