List of usage examples for javafx.beans.value ChangeListener ChangeListener
ChangeListener
From source file:de.micromata.mgc.javafx.launcher.gui.AbstractMainWindow.java
@Override public void initializeWithModel() { Thread currentThread = Thread.currentThread(); currentThread.setUncaughtExceptionHandler(model.getUncaughtExceptionHandler()); addCss();// w w w. j av a2 s. c om LauncherLocalSettingsConfigModel config = MgcLauncher.getLauncherConfig(); if (config.isEnableLF5() == false) { launchMenu.setVisible(false); } if (SystemService.get().getOsType() != OsType.Windows) { hideWindowMenu.setVisible(false); } stage.setOnCloseRequest(event -> { if (SystemService.get().getOsType() != OsType.Windows) { event.consume(); Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.title")); alert.setHeaderText( model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.header")); alert.setContentText( model.getTranslateService().translate("mgc.launcher.gui.quitconfirmation.message")); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { closeApplication(null); } } }); startServerButton.setOnAction(e -> { startServer(); }); stopServerButton.setOnAction(e -> { stopServer(); }); stopServerButton.setDisable(true); boolean runnin = MgcLauncher.get().getApplication().isRunning(); startServerButton.setDisable(runnin); stopServerButton.setDisable(runnin == false); openBrowser.setDisable(runnin == false); addStartServerEventHandler(); addStopServerEventHandler(); openBrowser.setOnAction(e -> { launchBrowser(); }); loggingPane.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { loggingController.adjustWidth(newSceneWidth.doubleValue()); } }); loggingPane.heightProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { loggingController.adjustHeight(newSceneWidth.doubleValue()); } }); loggingController.adjustHeight(loggingPane.getHeight()); loggingController.adjustWidth(loggingPane.getWidth()); MgcEventRegistries.getEventInstanceRegistry() .registerListener(new MgcApplicationStartStopToEventListener()); String helpUrl = getModel().getApplicationInfo().getHelpUrl(); if (StringUtils.isBlank(helpUrl) == true) { helpButton.setVisible(false); } else { helpButton.setOnAction(event -> { SystemService.get().openUrlInBrowser(helpUrl); }); } FXEvents.get().addEventHandler(this, stopServerButton, MgcLauncherEvent.APP_STARTED, event -> { if (config.isStartBrowserOnStartup() == true) { launchBrowser(); } }); }
From source file:com.rvantwisk.cnctools.operations.createRoundStock.CreateRoundStockController.java
@FXML void initialize() { // iName.textProperty().setValue(task.getName()); modelToForm();/*from w w w . j av a 2 s . co m*/ selectOrEditTool.addEventHandler(ToolChangedEvent.TOOL_CHANGED_EVENT, new EventHandler<ToolChangedEvent>() { @Override public void handle(ToolChangedEvent toolChangedEvent) { generateGCode(); } }); iFinalLength.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iFinalSize.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iStockSize.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); generateGCode(); }
From source file:com.offbynull.voip.ui.UiWebRegion.java
private UiWebRegion(Bus busFromGateway, Bus busToGateway) { Validate.notNull(busFromGateway);//from www . j a v a 2 s . c o m Validate.notNull(busToGateway); this.busFromGateway = busFromGateway; this.busToGateway = busToGateway; webView = new WebView(); webEngine = webView.getEngine(); webView.setContextMenuEnabled(false); webEngine.getLoadWorker().exceptionProperty().addListener(new ChangeListener<Throwable>() { @Override public void changed(ObservableValue<? extends Throwable> ov, Throwable t, Throwable t1) { System.out.println("Received exception: " + t1.getMessage()); } }); getChildren().add(webView); lock = new ReentrantLock(); }
From source file:poe.trade.assist.SearchPane.java
private void setupFilterTextField() { nameFilterField = new TextField(); nameFilterField.setMinWidth(200);/*from w w w.ja v a 2 s .co m*/ nameFilterField.setPromptText("filter by name"); tagFilterField = new TextField(); tagFilterField.setMinWidth(200); tagFilterField.setPromptText("filter by tags, csv"); showOnlyNew.setSelected(false); tagFilterField.textProperty().addListener((observable, oldValue, newValue) -> { searchTable.getFilteredData().setPredicate(tagPredicate().and(namePredicate())); }); nameFilterField.textProperty().addListener((observable, oldValue, newValue) -> { searchTable.getFilteredData().setPredicate(tagPredicate().and(namePredicate())); }); showOnlyNew.selectedProperty().addListener(new ChangeListener<Boolean>() { public void changed(ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) { searchTable.getFilteredData().setPredicate(onlyNewPredicate()); } }); }
From source file:gisintegration.SimpleSwingBrowser.java
private void createScene() { Platform.runLater(new Runnable() { @Override/*www .j a v a 2 s . c o m*/ public void run() { WebView view = new WebView(); engine = view.getEngine(); // engine.titleProperty().addListener(new ChangeListener<String>() { // @Override // public void changed(ObservableValue<? extends String> observable, String oldValue, final String newValue) { // SwingUtilities.invokeLater(new Runnable() { // @Override // public void run() { // SimpleSwingBrowser.this.setTitle(newValue); // } // }); // } // }); engine.setOnStatusChanged(new EventHandler<WebEvent<String>>() { @Override public void handle(final WebEvent<String> event) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { lblStatus.setText(event.getData()); } }); } }); // engine.locationProperty().addListener(new ChangeListener<String>() { // @Override // public void changed(ObservableValue<? extends String> ov, String oldValue, final String newValue) { // SwingUtilities.invokeLater(new Runnable() { // @Override // public void run() { // txtURL.setText(newValue); // } // }); // } // }); engine.getLoadWorker().workDoneProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, final Number newValue) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { progressBar.setValue(newValue.intValue()); } }); } }); engine.getLoadWorker().exceptionProperty().addListener(new ChangeListener<Throwable>() { public void changed(ObservableValue<? extends Throwable> o, Throwable old, final Throwable value) { if (engine.getLoadWorker().getState() == FAILED) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(panel, (value != null) ? engine.getLocation() + "\n" + value.getMessage() : engine.getLocation() + "\nUnexpected error.", "Loading error...", JOptionPane.ERROR_MESSAGE); } }); } } }); jfxPanel.setScene(new Scene(view)); } }); }
From source file:pl.baczkowicz.mqttspy.ui.NewPublicationController.java
public void initialize(URL location, ResourceBundle resources) { timeBasedFilter = new TimeBasedKeyEventFilter(15); publicationTopicText.setItems(publicationTopics); formatGroup.getToggles().get(0).setUserData(ConversionMethod.PLAIN); formatGroup.getToggles().get(1).setUserData(ConversionMethod.HEX_DECODE); formatGroup.selectToggle(formatGroup.getToggles().get(0)); formatGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override// w w w .jav a 2 s .com public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { // If plain has been selected if (newValue != null) { if (formatGroup.getSelectedToggle().getUserData().equals(ConversionMethod.PLAIN)) { showAsPlain(); } else { showAsHex(); } } } }); publicationTopicText.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent keyEvent) { switch (keyEvent.getCode()) { case ENTER: { if (connected && timeBasedFilter.processEvent(keyEvent)) { publish(); keyEvent.consume(); } break; } case DIGIT0: { restoreFromKeypress(keyEvent, 0); break; } case DIGIT1: { restoreFromKeypress(keyEvent, 1); break; } case DIGIT2: { restoreFromKeypress(keyEvent, 2); break; } case DIGIT3: { restoreFromKeypress(keyEvent, 3); break; } case DIGIT4: { restoreFromKeypress(keyEvent, 4); break; } case DIGIT5: { restoreFromKeypress(keyEvent, 5); break; } case DIGIT6: { restoreFromKeypress(keyEvent, 6); break; } case DIGIT7: { restoreFromKeypress(keyEvent, 7); break; } case DIGIT8: { restoreFromKeypress(keyEvent, 8); break; } case DIGIT9: { restoreFromKeypress(keyEvent, 9); break; } default: break; } } }); publicationData.setWrapText(true); publishScript.getToggles().get(0).setUserData(null); //paneStatus.setVisibility(PaneVisibilityStatus.NOT_VISIBLE); }
From source file:org.noroomattheinn.visibletesla.LocationController.java
private void reflectInternal(StreamState ss) { String latitude = String.valueOf(ss.estLat); String longitude = String.valueOf(ss.estLng); String heading = String.valueOf(ss.estHeading); if (mapIsLoaded) { try {/*from w ww . ja v a 2 s . com*/ engine.executeScript(String.format("moveMarker(%s, %s, %s)", latitude, longitude, heading)); } catch (Exception e) { logger.warning(e.toString()); } } else { String mapHTML = getMapFromTemplate(latitude, longitude, heading); engine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() { @Override public void changed(ObservableValue ov, State old, State cur) { if (cur == State.SUCCEEDED) { mapIsLoaded = true; stopBlip(blipAnimation); loadingImage.setVisible(false); loadingImageLabel.setVisible(false); } } }); engine.loadContent(mapHTML); // This code can be used to communicate events back from javascript in // the html code to this Java code. The javascript code would do something // like: window.status = "load complete"; and that message would be passed // to this onStatusChanged handler. // engine.setOnStatusChanged(new EventHandler<WebEvent<java.lang.String>>() { // @Override public void handle(WebEvent<String> t) { // logger.log(Level.INFO, "Status Change: " + t.getData()); // } // }); } multigauge.setVal(Side.LEFT, useMiles ? ss.speed : Utils.milesToKm(ss.speed)); multigauge.setVal(Side.RIGHT, ss.power); }
From source file:org.jevis.jeconfig.JEConfig.java
/** * Build an new JEConfig Login and main frame/stage * * @param primaryStage/*from w ww .j a va 2 s . c o m*/ */ //AITBilal - Login private void initGUI(Stage primaryStage) { Scene scene; LoginGlass login = new LoginGlass(primaryStage); AnchorPane jeconfigRoot = new AnchorPane(); AnchorPane.setTopAnchor(jeconfigRoot, 0.0); AnchorPane.setRightAnchor(jeconfigRoot, 0.0); AnchorPane.setLeftAnchor(jeconfigRoot, 0.0); AnchorPane.setBottomAnchor(jeconfigRoot, 0.0); // jeconfigRoot.setStyle("-fx-background-color: white;"); // jeconfigRoot.getChildren().setAll(new Label("sodfhsdhdsofhdshdsfdshfjf")); Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); // @AITBilal - Main frame elemente wird aufgerufen nachdem man sich eingeloggt hat. login.getLoginStatus().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { System.out.println("after request"); _mainDS = login.getDataSource(); ds = _mainDS; Platform.runLater(new Runnable() { @Override public void run() { FadeTransition ft = new FadeTransition(Duration.millis(1500), login); ft.setFromValue(1.0); ft.setToValue(0); ft.setCycleCount(1); ft.play(); } }); JEConfig.PROGRAMM_INFO.setJEVisAPI(ds.getInfo()); JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.commons.application.Info.INFO); JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.application.Info.INFO); preLodedClasses = login.getAllClasses(); preLodedRootObjects = login.getRootObjects(); PluginManager pMan = new PluginManager(ds); //@AITBilal - Toolbar fr save, newB, delete, sep1, form GlobalToolBar toolbar = new GlobalToolBar(pMan); pMan.addPluginsByUserSetting(null); // StackPane root = new StackPane(); // root.setId("mainpane"); BorderPane border = new BorderPane(); VBox vbox = new VBox(); vbox.getChildren().addAll(new TopMenu(), toolbar.ToolBarFactory()); border.setTop(vbox); //@AITBilal - Alle Plugins Inhalt fr JEConfig (Resources... | System | Attribute) border.setCenter(pMan.getView()); Statusbar statusBar = new Statusbar(ds); border.setBottom(statusBar); System.out.println("show welcome"); //Disable GUI is StatusBar note an disconnect border.disableProperty().bind(statusBar.connectedProperty.not()); Platform.runLater(new Runnable() { @Override public void run() { AnchorPane.setTopAnchor(border, 0.0); AnchorPane.setRightAnchor(border, 0.0); AnchorPane.setLeftAnchor(border, 0.0); AnchorPane.setBottomAnchor(border, 0.0); jeconfigRoot.getChildren().setAll(border); // try { // WelcomePage welcome = new WelcomePage(primaryStage, new URI("http://coffee-project.eu/")); // WelcomePage welcome = new WelcomePage(primaryStage, new URI("http://openjevis.org/projects/openjevis/wiki/JEConfig3#JEConfig-Version-3")); // Task<Void> showWelcome = new Task<Void>() { // @Override // protected Void call() throws Exception { try { WelcomePage welcome = new WelcomePage(primaryStage, _config.getWelcomeURL()); } catch (URISyntaxException ex) { Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); } // return null; // } // }; // new Thread(showWelcome).start(); // WelcomePage welcome = new WelcomePage(primaryStage, _config.getWelcomeURL()); // } catch (URISyntaxException ex) { // Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); // } catch (MalformedURLException ex) { // Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); // } } }); } } }); AnchorPane.setTopAnchor(login, 0.0); AnchorPane.setRightAnchor(login, 0.0); AnchorPane.setLeftAnchor(login, 0.0); AnchorPane.setBottomAnchor(login, 0.0); //@AITBilal - Login Dialog scene = new Scene(jeconfigRoot, bounds.getWidth(), bounds.getHeight()); scene.getStylesheets().add("/styles/Styles.css"); primaryStage.getIcons().add(getImage("1393354629_Config-Tools.png")); primaryStage.setTitle("JEConfig"); primaryStage.setScene(scene); maximize(primaryStage); primaryStage.show(); // Platform.runLater(new Runnable() { // @Override // public void run() { //@AITBilal - Inhalt bzw. die Elemente von LoginDialog jeconfigRoot.getChildren().setAll(login); // } // }); primaryStage.onCloseRequestProperty().addListener(new ChangeListener<EventHandler<WindowEvent>>() { @Override public void changed(ObservableValue<? extends EventHandler<WindowEvent>> ov, EventHandler<WindowEvent> t, EventHandler<WindowEvent> t1) { try { System.out.println("Disconnect"); ds.disconnect(); } catch (JEVisException ex) { Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); } } }); }
From source file:nl.mvdr.umvc3replayanalyser.controller.EditReplayController.java
/** Initialisation method. */ // Default visibility for unit tests. @FXML//from w w w . ja v a 2s . co m void initialize() { log.info("Performing controller initialisation."); // Initialise character combo boxes. for (ComboBox<Umvc3Character> comboBox : Arrays.asList(playerOneCharacterOneComboBox, playerOneCharacterTwoComboBox, playerOneCharacterThreeComboBox, playerTwoCharacterOneComboBox, playerTwoCharacterTwoComboBox, playerTwoCharacterThreeComboBox)) { comboBox.getItems().addAll(Umvc3Character.values()); } // Initialise assist combo boxes. assistComboBoxes = new HashMap<>(); assistComboBoxes.put(playerOneCharacterOneComboBox.valueProperty(), playerOneAssistOneComboBox); assistComboBoxes.put(playerOneCharacterTwoComboBox.valueProperty(), playerOneAssistTwoComboBox); assistComboBoxes.put(playerOneCharacterThreeComboBox.valueProperty(), playerOneAssistThreeComboBox); assistComboBoxes.put(playerTwoCharacterOneComboBox.valueProperty(), playerTwoAssistOneComboBox); assistComboBoxes.put(playerTwoCharacterTwoComboBox.valueProperty(), playerTwoAssistTwoComboBox); assistComboBoxes.put(playerTwoCharacterThreeComboBox.valueProperty(), playerTwoAssistThreeComboBox); // Add a listener, so that whenever a character value is changed, the assist combo box is updated as well. ChangeListener<Umvc3Character> assistListener = new ChangeListener<Umvc3Character>() { /** {@inheritDoc} */ @Override public void changed(ObservableValue<? extends Umvc3Character> observable, Umvc3Character oldValue, Umvc3Character newValue) { if (log.isDebugEnabled()) { log.debug(String.format("Character changed. Old value: %s, new value: %s", oldValue, newValue)); } updateAssistComboBox(observable); } }; playerOneCharacterOneComboBox.valueProperty().addListener(assistListener); playerOneCharacterTwoComboBox.valueProperty().addListener(assistListener); playerOneCharacterThreeComboBox.valueProperty().addListener(assistListener); playerTwoCharacterOneComboBox.valueProperty().addListener(assistListener); playerTwoCharacterTwoComboBox.valueProperty().addListener(assistListener); playerTwoCharacterThreeComboBox.valueProperty().addListener(assistListener); // Add another listener to ensure the OK button is enabled when the required fields have been filled in. ChangeListener<Object> okEnabledListener = new ChangeListener<Object>() { /** {@inheritDoc} */ @Override public void changed(ObservableValue<? extends Object> observable, Object oldValue, Object newValue) { if (log.isDebugEnabled()) { log.debug(String.format("Observable value changed. Old value: %s, new value: %s", oldValue, newValue)); } okButton.setDisable(!isFilledIn()); } }; playerOneTextField.textProperty().addListener(okEnabledListener); playerTwoTextField.textProperty().addListener(okEnabledListener); playerOneCharacterOneComboBox.valueProperty().addListener(okEnabledListener); playerOneCharacterTwoComboBox.valueProperty().addListener(okEnabledListener); playerOneCharacterThreeComboBox.valueProperty().addListener(okEnabledListener); playerTwoCharacterOneComboBox.valueProperty().addListener(okEnabledListener); playerTwoCharacterTwoComboBox.valueProperty().addListener(okEnabledListener); playerTwoCharacterThreeComboBox.valueProperty().addListener(okEnabledListener); // Set the value of all fields based on the contents of defaultContents if available. // Do this after registering the listeners, so that when a character value is set, the assist combo box is // updated, and the status of the OK button is updated at the end. // Always update the assist value after the corresponding character value. if (defaultContents != null) { playerOneTextField.setText(defaultContents.getPlayerOne().getGamertag()); playerTwoTextField.setText(defaultContents.getPlayerTwo().getGamertag()); Team teamOne = defaultContents.getTeamOne(); Team teamTwo = defaultContents.getTeamTwo(); playerOneCharacterOneComboBox.setValue(teamOne.getFirstCharacter()); playerOneAssistOneComboBox.setValue(teamOne.getFirstAssist()); playerOneCharacterTwoComboBox.setValue(teamOne.getSecondCharacter()); playerOneAssistTwoComboBox.setValue(teamOne.getSecondAssist()); playerOneCharacterThreeComboBox.setValue(teamOne.getThirdCharacter()); playerOneAssistThreeComboBox.setValue(teamOne.getThirdAssist()); playerTwoCharacterOneComboBox.setValue(teamTwo.getFirstCharacter()); playerTwoAssistOneComboBox.setValue(teamTwo.getFirstAssist()); playerTwoCharacterTwoComboBox.setValue(teamTwo.getSecondCharacter()); playerTwoAssistTwoComboBox.setValue(teamTwo.getSecondAssist()); playerTwoCharacterThreeComboBox.setValue(teamTwo.getThirdCharacter()); playerTwoAssistThreeComboBox.setValue(teamTwo.getThirdAssist()); } log.info("Initialisation complete."); }
From source file:com.rvantwisk.cnctools.controllers.ToolConfigurationsController.java
@FXML void initialize() { v_toolsList.setItems(toolDBManager.getToolDB()); setMode(this.mode); // toolConfig.con toolParameters.disableProperty().bind(v_toolsList.getSelectionModel().selectedItemProperty().isNull()); btnCopy.disableProperty().bind(v_toolsList.getSelectionModel().selectedItemProperty().isNull()); btnDelete.disableProperty().bind(v_toolsList.getSelectionModel().selectedItemProperty().isNull()); // When the user selects a item in the list then update the tool panel v_toolsList.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ToolParameter>() { @Override/*from w w w . j ava2 s . c o m*/ public void changed(ObservableValue<? extends ToolParameter> observable, ToolParameter oldValue, ToolParameter newValue) { if (v_toolsList.getSelectionModel().selectedItemProperty().get() == null) { toolParameters.setTool(null); // toolParametersController.setTool(new ToolParameter("", ToolParameter.Units.MM, new EndMill(6.0))); } else { toolParameters.setTool(newValue); } } }); // Set text in ListView v_toolsList.setCellFactory(new Callback<ListView<ToolParameter>, ListCell<ToolParameter>>() { @Override public ListCell<ToolParameter> call(ListView<ToolParameter> p) { ListCell<ToolParameter> cell = new ListCell<ToolParameter>() { @Override protected void updateItem(ToolParameter t, boolean bln) { super.updateItem(t, bln); this.textProperty().unbind(); if (t != null) { textProperty().bind(t.nameProperty()); } else { textProperty().setValue(""); } } }; return cell; } }); }