Java Code Examples for javafx.beans.value.ObservableValue

The following are top voted examples for showing how to use javafx.beans.value.ObservableValue. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Squid   File: IsotopesManagerController.java   Source Code and License 9 votes vote down vote up
private void createTextField() {
    textField = new TextField(getString());
    textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
    textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> arg0,
                Boolean arg1, Boolean arg2) {
            if (!arg2) {
                commitEdit(textField.getText());
            }
        }
    });

    textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
        @Override
        public void handle(KeyEvent ke) {
            KeyCode kc = ke.getCode();
            if ((kc.equals(KeyCode.ENTER) || kc.equals(KeyCode.UP) || kc.equals(KeyCode.DOWN) || kc.equals(KeyCode.LEFT) || kc.equals(KeyCode.RIGHT))) {
                commitEdit(textField.getText());
            }
        }
    });
}
 
Example 2
Project: OftenPorter   File: MenuItemBinder.java   Source Code and License 7 votes vote down vote up
public MenuItemBinder(MenuItem menuItem)
{
    super(menuItem);
    actionHandler = new EventHandler<ActionEvent>()
    {
        @Override
        public void handle(ActionEvent event)
        {
            onOccur();
        }
    };
    menuItem.addEventHandler(ActionEvent.ACTION,actionHandler);
    changeListener = new ChangeListener<String>()
    {
        @Override
        public synchronized void changed(ObservableValue<? extends String> observable, String oldValue,
                String newValue)
        {
            doOnchange(oldValue,newValue);
        }
    };
    menuItem.textProperty().addListener(changeListener);
}
 
Example 3
Project: incubator-netbeans   File: WebViewBrowser.java   Source Code and License 7 votes vote down vote up
public WebViewPane() {
    VBox.setVgrow(this, Priority.ALWAYS);
    setMaxWidth(Double.MAX_VALUE);
    setMaxHeight(Double.MAX_VALUE);

    WebView view = new WebView();
    view.setMinSize(500, 400);
    view.setPrefSize(500, 400);
    final WebEngine eng = view.getEngine();
    eng.load("http://www.oracle.com/us/index.html");
    final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
    locationField.setMaxHeight(Double.MAX_VALUE);
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
                    "http://" + locationField.getText());
        }
    };
    goButton.setOnAction(goAction);
    locationField.setOnAction(goAction);
    eng.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(5);
    GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
    GridPane.setConstraints(goButton,1,0);
    GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
    grid.getColumnConstraints().addAll(
            new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
            new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
    );
    grid.getChildren().addAll(locationField, goButton, view);
    getChildren().add(grid);
}
 
Example 4
Project: ABC-List   File: CheckBoxListCell.java   Source Code and License 6 votes vote down vote up
public CheckBoxListCell(
        final Callback<T, ObservableValue<Boolean>> getSelectedProperty, 
        final BooleanProperty disableProperty,
        final StringConverter<T> converter
) {
    this.getStyleClass().add("check-box-list-cell");
    setSelectedStateCallback(getSelectedProperty);
    setConverter(converter);
    
    checkBox = new CheckBox();
    checkBox.disableProperty().bind(disableProperty);
    
    setAlignment(Pos.CENTER_LEFT);
    setContentDisplay(ContentDisplay.LEFT);

    // by default the graphic is null until the cell stops being empty
    setGraphic(null);
}
 
Example 5
Project: LivroJavaComoProgramar10Edicao   File: TipCalculatorController.java   Source Code and License 6 votes vote down vote up
public void initialize() 
{
   // 0-4 rounds down, 5-9 rounds up 
   currency.setRoundingMode(RoundingMode.HALF_UP);
   
   // listener for changes to tipPercentageSlider's value
   tipPercentageSlider.valueProperty().addListener(
      new ChangeListener<Number>() 
      {
         @Override
         public void changed(ObservableValue<? extends Number> ov, 
            Number oldValue, Number newValue) 
         {
            tipPercentage = 
               BigDecimal.valueOf(newValue.intValue() / 100.0);
            tipPercentageLabel.setText(percent.format(tipPercentage));
         }
      }
   );
}
 
Example 6
Project: Dr-Assistant   File: PatientsController.java   Source Code and License 6 votes vote down vote up
/**
 * Initializes the controller class.
 *
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    scrollPan.viewportBoundsProperty().addListener((ObservableValue<? extends Bounds> observable, Bounds oldValue, Bounds newValue) -> {
        flowPane.setPrefWidth(newValue.getWidth());
    });

    lblTotalPatient.setText("Loading..........");

    Platform.runLater(() -> {
        totalPatient = patientGetway.totalPatient();
        loadPatients();
        lblTotalPatient.setText("Total :" + totalPatient);
        lblShowingPatient.setText("Showing " + paginate.getStart() + " To " + paginate.getEnd());
        if (totalPatient == 0) {
            lblTotalPatient.setText("No patient found");
            lblShowingPatient.setVisible(false);
        }
    });

}
 
Example 7
Project: Money-Manager   File: TransactionHistoryController.java   Source Code and License 6 votes vote down vote up
@FXML
	private void btnGo(ActionEvent event) {
		historyByDate = new HistorySearchByDate(datePicker.getValue());
		
		webEngine.getLoadWorker().stateProperty().addListener(
        	    new ChangeListener<Worker.State>() {
        	        @Override
        	        public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
        	            if (newValue == Worker.State.SUCCEEDED) {
        	                JSObject windowObject = (JSObject) webEngine.executeScript("window");
        	                windowObject.setMember("HistorySearchByDate", historyByDate); // insert object
        	                windowObject.call("searchHistoryByDate"); // execute callback
        	            }
        	        }
        	    }
        	);
		URL url = getClass().getResource("/html/index.html");
        webEngine.load(url.toString());
		
//        String url = getClass().getResource("../html/index.html").toExternalForm();
//        webEngine.load(url);
	}
 
Example 8
Project: twichat   File: Controller.java   Source Code and License 6 votes vote down vote up
@Override
  public void initialize(URL location, ResourceBundle resources) {
  	Main.bot.currentChannel = Main.bot.getChannels().get(0);
vbox.setSpacing(30);

      System.out.println("initialized");
      updateViewCount();
      
      new Timer().schedule(new TimerTask() {
	
	@Override
	public void run() {
		Platform.runLater(() -> { Controller.controller.viewCount
			.setText("Viewers: " + Main.bot.getChannels().get(0).getViewersNum()); });
		
	}
}, 0, 10000);

      vbox.heightProperty().addListener(new ChangeListener<Number>() {
	@Override
	public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
		scrollPane.setVvalue(1.0);
	}
});
      
  }
 
Example 9
Project: marathonv5   File: JavaFXCheckBoxTreeTableCell.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public String _getValue() {
    CheckBoxTreeTableCell cell = (CheckBoxTreeTableCell) node;
    Callback selectedStateCallback = cell.getSelectedStateCallback();
    String cbText;
    if (selectedStateCallback != null) {
        ObservableValue<Boolean> call = (ObservableValue<Boolean>) selectedStateCallback.call(cell.getItem());
        int selection = call.getValue() ? 2 : 0;
        cbText = JavaFXCheckBoxElement.states[selection];
    } else {
        Node cb = cell.getGraphic();
        JavaFXElement comp = (JavaFXElement) JavaFXElementFactory.createElement(cb, driver, window);
        cbText = comp._getValue();

    }
    String cellText = cell.getText();
    if (cellText == null) {
        cellText = "";
    }
    String text = cellText + ":" + cbText;
    return text;
}
 
Example 10
Project: CSS-Editor-FX   File: StatusBarManager.java   Source Code and License 6 votes vote down vote up
private static <T> StringBinding mapString(ObservableValue<T> v, Function<T, String> func) {
  return new StringBinding() {
    {
      bind(v);
    }

    @Override
    protected String computeValue() {
      if (v.getValue() == null) {
        return "";
      } else {
        return func.apply(v.getValue());
      }
    }
  };
}
 
Example 11
Project: GazePlay   File: ConfigurationContext.java   Source Code and License 6 votes vote down vote up
private static ChoiceBox<EyeTracker> buildEyeTrackerConfigChooser(Configuration configuration,
        ConfigurationContext configurationContext) {
    ChoiceBox<EyeTracker> choiceBox = new ChoiceBox<>();

    choiceBox.getItems().addAll(EyeTracker.values());

    EyeTracker selectedEyeTracker = findSelectedEyeTracker(configuration);
    choiceBox.getSelectionModel().select(selectedEyeTracker);

    choiceBox.setPrefWidth(prefWidth);
    choiceBox.setPrefHeight(prefHeight);

    choiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<EyeTracker>() {
        @Override
        public void changed(ObservableValue<? extends EyeTracker> observable, EyeTracker oldValue,
                EyeTracker newValue) {
            final String newPropertyValue = newValue.name();
            ConfigurationBuilder.createFromPropertiesResource().withEyeTracker(newPropertyValue)
                    .saveConfigIgnoringExceptions();
        }
    });

    return choiceBox;
}
 
Example 12
Project: dragdropfx   File: DnDPrepare.java   Source Code and License 6 votes vote down vote up
public static void tableColumns(final Visitor v, List<? extends TableColumn<?, ?>> addedSubList) {
	for(int i = 0; i < addedSubList.size(); i++){
		final TableColumn<?,?> col = addedSubList.get(i);
		
		col.setCellFactory(new DnDTableCellFactory(v, col.getCellFactory()));
		col.cellFactoryProperty().addListener(new ChangeListener<Callback>() {
			@Override
			public void changed(ObservableValue<? extends Callback> observable, Callback oldValue,
					Callback newValue) {
				if(!(newValue instanceof DnDTableCellFactory)){
					col.setCellFactory(new DnDTableCellFactory(v, col.getCellFactory()));
				}
			}
		});
	}
}
 
Example 13
Project: dss-demonstrations   File: TypedToggleGroup.java   Source Code and License 6 votes vote down vote up
public TypedToggleGroup() {

		this.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
			@Override
			@SuppressWarnings("unchecked")
			public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
				if (newValue != null) {
					T obj = (T) newValue.getUserData();
					selectedValueProperty.setValue(obj);
				} else {
					selectedValueProperty.setValue(null);
				}
			}
		});

	}
 
Example 14
Project: JavaFX-Web-Browser   File: WebBrowserTabController.java   Source Code and License 5 votes vote down vote up
@Override
		public void changed(ObservableValue<? extends State> observable, State oldState, State newState) {
			if (newState == Worker.State.CANCELLED) {
			// download detected
			String url = webEngine.getLocation();
			logger.info("download url: "+url);
//             try{
//                 Download download = new Download(webEngine.getLocation());
//                 Thread t = new Thread(download);
//                 t.start();
//             }catch(Exception ex){
//                 logger.log(Level.SEVERE, "download", ex);
//             }
			}
		}
 
Example 15
Project: Suji   File: GameListController.java   Source Code and License 5 votes vote down vote up
private void spectateGame(GameList.Game game) {
	SpectatorGameHandler handler = new SpectatorGameHandler(game.getId());
	BoardController controller = new BoardController(handler, "/fxml/localGame.fxml", false);

	PlayerPaneController playerInfo = new PlayerPaneController(game);
	controller.addToSideBar(playerInfo.getRoot());

	DockNode node = controller.getDockNode();
	node.closedProperty().addListener(new ChangeListener<Boolean>() {
		@Override
		public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
			if ( newValue ) {
				handler.disconnect();
				observable.removeListener(this);
			}
		}
	});
	node.setTitle(game.getGameName());
	node.dock(Main.instance.dockPane, DockPos.CENTER);
}
 
Example 16
Project: Dr-Assistant   File: NewTemplateController.java   Source Code and License 5 votes vote down vote up
private void loadDrug() {
    drugs = drugGetway.allDrugs();
    comboBoxDrug.getItems().addAll(drugs);
    comboBoxDrug.setConverter(new StringConverter<Drug>() {
        @Override
        public String toString(Drug object) {
            return object.getName();
        }

        @Override
        public Drug fromString(String string) {
            return comboBoxDrug.getItems().stream().filter(ap -> ap.getName().equals(string)).findFirst().orElse(null);
        }
    });
    comboBoxDrug.getSelectionModel().selectFirst();
    comboBoxDrug.setOnKeyReleased((KeyEvent event) -> {
        drugs.forEach((drug) -> {
            if (String.valueOf(event.getText()).matches(Character.toString(drug.getName().charAt(0)))) {
                comboBoxDrug.setValue(drug);
            }
        });
    });
    comboBoxDrug.getSelectionModel().selectedItemProperty().addListener((ObservableValue<? extends Drug> observable, Drug oldValue, Drug newValue) -> {
        System.out.println("Selected drug id : " + newValue.getId() + " Name : " + newValue.getName());
    });
}
 
Example 17
Project: SnapDup   File: TableViewSelection.java   Source Code and License 5 votes vote down vote up
@Override
public void changed(ObservableValue<? extends DupData> observable, DupData oldValue, DupData newValue)
{
	if(newValue != null)
	{
		Platform.runLater(() -> {
			txtArea.selectRange(newValue.getStartOffset(), newValue.getEndOffset());
		});
	}
}
 
Example 18
Project: OftenPorter   File: TextBinder.java   Source Code and License 5 votes vote down vote up
public TextBinder(final TextInputControl view)
{
    super(view);

    changeListener = new ChangeListener<String>()
    {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue)
        {
            doOnchange(oldValue,newValue);
        }
    };
    view.textProperty().addListener(changeListener);
}
 
Example 19
Project: desktop-gmail-client   File: MainUI3Controller.java   Source Code and License 5 votes vote down vote up
public void setDraftListView(){
    draftMessageListView = new JFXListView<>();
    draftMessageListView.setItems(GmailMessages.draftMessages);
    draftMessageListView.setCellFactory(new Callback<ListView<FormattedMessage>, ListCell<FormattedMessage>>() {
        @Override
        public ListCell<FormattedMessage> call(ListView<FormattedMessage> param) {
            return new CustomListCell(currentFolderName);
        }
    });
    draftMessageListView.getStylesheets().add(String.valueOf(getClass().getResource("/listview.css")));
    draftMessageListView.setExpanded(true);
    draftMessageListView.depthProperty().set(1);

    draftMessageListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<FormattedMessage>() {
        @Override
        public void changed(ObservableValue<? extends FormattedMessage> observable, FormattedMessage oldValue, FormattedMessage newValue) {
            if (newValue != null) {
                if (!componentFlag) {
                    componentFlag = true;
                    screenComponent.setScreenComponent(currentFolderName);
                    setScreenComponent();
                }
                screenComponent.setInfo(newValue);
            }
        }
    });
}
 
Example 20
Project: desktop-gmail-client   File: MainUI3Controller.java   Source Code and License 5 votes vote down vote up
public void setTrashListView(){
    trashMessageListView = new JFXListView<>();
    trashMessageListView.setItems(GmailMessages.trashMessages);
    trashMessageListView.setCellFactory(new Callback<ListView<FormattedMessage>, ListCell<FormattedMessage>>() {
        @Override
        public ListCell<FormattedMessage> call(ListView<FormattedMessage> param) {
            return new CustomListCell(currentFolderName);
        }
    });
    trashMessageListView.getStylesheets().add(String.valueOf(getClass().getResource("/listview.css")));
    trashMessageListView.setExpanded(true);
    trashMessageListView.depthProperty().set(1);

    trashMessageListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<FormattedMessage>() {
        @Override
        public void changed(ObservableValue<? extends FormattedMessage> observable, FormattedMessage oldValue, FormattedMessage newValue) {
            if (newValue != null) {
                if (!componentFlag) {
                    componentFlag = true;
                    screenComponent.setScreenComponent(currentFolderName);
                    setScreenComponent();
                }
                screenComponent.setInfo(newValue);
            }
        }
    });
    /*ScrollBar listViewScrollBar = getListViewScrollBar(trashMessageListView);
    listViewScrollBar.valueProperty().addListener((observable, oldValue, newValue) -> {
        double position = newValue.doubleValue();
        ScrollBar scrollBar = getListViewScrollBar(trashMessageListView);
        if (position == scrollBar.getMax()) {
            try {
                GmailMessages.trashMessages.addAll(GmailOperations.getTrashMessages(10));
            } catch (IOException e) {
                e.printStackTrace();
                NotifyUser.getNotification("Internet connection has lost", "Please check your internet connection").showInformation();
            }
        }
    });*/
}
 
Example 21
Project: Quantify   File: MultiTabsDialogController.java   Source Code and License 5 votes vote down vote up
public void setTabs(List<Data> data) {

        // add tabs
        for (int i = 1; i <= data.size(); i++) {
            Tab tab = new Tab("case " + i);
            tab.setClosable(false);
            tabPane.getTabs().add(tab);
        }

        // clear tabs
        tabPane.getSelectionModel().clearSelection();

        tabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Tab>() {
            @Override
            public void changed(ObservableValue<? extends Tab> observable, Tab oldValue, Tab newValue) {
                if (null == newValue.getContent()) {
                    try {
                        FXMLLoader loader = new FXMLLoader();
                        loader.setLocation(getClass().getResource("../view/QuantifyStatistics.fxml"));
                        Parent root = loader.load();
                        newValue.setContent(root);

                        QuantifyStatisticsController controller = loader.getController();
                        int index = tabPane.getSelectionModel().getSelectedIndex();
                        controller.setQuantifyData(data.get(index));

                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
    }
 
Example 22
Project: PearPlanner   File: TaskController.java   Source Code and License 5 votes vote down vote up
/**
 * Creates a Task selection window.
 *
 * @param list List of Tasks to be put into the window.
 * @return A list of selected Tasks
 */
protected static ObservableList<Task> taskSelectionWindow(ObservableList<Task> list)
{
    // Layout:
    VBox layout = new VBox();
    layout.setSpacing(10);
    layout.setAlignment(Pos.BOTTOM_RIGHT);
    // =================

    // Tasks columns:
    TableColumn<Task, String> nameColumn = new TableColumn<>("Task");
    nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));

    TableColumn<Task, String> assignmentColumn = new TableColumn<>("Assignments");
    assignmentColumn.setCellValueFactory(new PropertyValueFactory("assignments")
    {
        @Override public ObservableValue call(TableColumn.CellDataFeatures param)
        {
            SimpleStringProperty value = new SimpleStringProperty("");
            for (Assignment a : ((Task) param.getValue()).getAssignmentReferences())
                value.set(value.getValue() + a.getName() + "\n");
            return value;
        }
    });

    TableColumn<Task, String> deadlineColumn = new TableColumn<>("Deadline");
    deadlineColumn.setCellValueFactory(new PropertyValueFactory<>("deadline"));
    deadlineColumn.setStyle("-fx-alignment: CENTER-RIGHT;");
    // =================

    // Create a table:
    TableView<Task> tasks = new TableView<>();
    tasks.setItems(list);
    tasks.getColumns().addAll(nameColumn, assignmentColumn, deadlineColumn);
    tasks.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    // =================

    // Table attributes:
    tasks.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    GridPane.setHgrow(tasks, Priority.ALWAYS);
    GridPane.setVgrow(tasks, Priority.ALWAYS);
    // =================

    // Set click event:
    tasks.setRowFactory(TaskController::taskRowFactory);
    // =================

    // Button:
    Button OK = new Button("OK");
    OK.setOnAction(e -> {
        Stage current = (Stage) OK.getScene().getWindow();
        current.close();
    });
    VBox.setMargin(OK, new Insets(5));
    OK.setDefaultButton(true);
    // =================

    layout.getChildren().addAll(tasks, OK);

    // Set a new scene:
    Stage stage = new Stage();
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setScene(new Scene(layout, 550, 300));
    stage.setTitle("Select dependencies");
    stage.getIcons().add(new Image("file:icon.png"));
    stage.showAndWait();
    // =================

    return tasks.getSelectionModel().getSelectedItems();
}
 
Example 23
Project: GameAuthoringEnvironment   File: FacebookListener.java   Source Code and License 5 votes vote down vote up
/**
 * Method to overwrite to listen to changes in the web browser
 */
@Override
public void changed (ObservableValue<? extends State> ov, State oldState, State newState) {
    if (newState == Worker.State.SUCCEEDED) {
        String newURL = myEngine.getLocation();
        checkForLogin(newURL);

    }
}
 
Example 24
Project: incubator-netbeans   File: HtmlComponent.java   Source Code and License 5 votes vote down vote up
private void initFX() {
    Platform.setImplicitExit(false);
    v = new WebView();
    BorderPane bp = new BorderPane();
    Scene scene = new Scene(bp, Color.ALICEBLUE);

    class X implements ChangeListener<String>, Runnable {

        private String title;

        public X() {
            super();
        }

        @Override
        public void changed(ObservableValue<? extends String> ov, String t, String t1) {
            title = v.getEngine().getTitle();
            EventQueue.invokeLater(this);
        }

        @Override
        public void run() {
            if (title != null) {
                HtmlComponent.this.setDisplayName(title);
            }
        }
    }
    final X x = new X();
    v.getEngine().titleProperty().addListener(x);
    Platform.runLater(x);
    bp.setCenter(v);
    p.setScene(scene);
}
 
Example 25
Project: plep   File: ChangeListenerWithBlocker.java   Source Code and License 5 votes vote down vote up
/**
 * Execute the listener passed in the constructor only of not blocked.
 * @param observable ObservableValue to add listener to?
 * @param oldValue The old value that has been changed.
 * @param newValue The new value the old value has been changed to.
 */
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean
        oldValue, Boolean newValue) {
    if(!block) {
        decoratedListener.changed(observable, oldValue, newValue);
    }
}
 
Example 26
Project: OftenPorter   File: CheckBoxBinder.java   Source Code and License 5 votes vote down vote up
public CheckBoxBinder(CheckBox view)
{
    super(view);
    changeListener = new ChangeListener<Boolean>()
    {
        @Override
        public synchronized void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue)
        {
            doOnchange(oldValue,newValue);
        }
    };
    view.selectedProperty().addListener(changeListener);
}
 
Example 27
Project: marathonv5   File: ProductFetcherTask.java   Source Code and License 5 votes vote down vote up
public ProductFetcherTask(final TableView products) {
    valueProperty().addListener(new ChangeListener<ObservableList<FullProductListing>>() {
        @Override public void changed(ObservableValue<? extends ObservableList<FullProductListing>> ov, 
                ObservableList<FullProductListing> oldValues, ObservableList<FullProductListing> newValues) {
            // insert results into table
            products.setItems(newValues);
            // remove progress indicator
            products.setPlaceholder(null);
        }
    });
}
 
Example 28
Project: waterrower-workout   File: HyperlinkRedirectListener.java   Source Code and License 5 votes vote down vote up
@Override
public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
    if (SUCCEEDED.equals(newValue)) {
        Document document = webView.getEngine().getDocument();
        NodeList anchors = document.getElementsByTagName(ANCHOR_TAG);
        for (int i = 0; i < anchors.getLength(); i++) {
            Node node = anchors.item(i);
            EventTarget eventTarget = (EventTarget) node;
            eventTarget.addEventListener(CLICK_EVENT, this, false);
        }
    }
}
 
Example 29
Project: FlashLib   File: LogWindow.java   Source Code and License 5 votes vote down vote up
private Scene loadScene(){
	BorderPane root = new BorderPane();
	
	textArea = new TextArea();
	textArea.setEditable(false);
	textArea.setPrefSize(300, 200);
	root.setCenter(textArea);
	BorderPane.setAlignment(root, Pos.CENTER);
	
	tabs = new TabPane();
	for (RemoteLog remoteLog : logs) {
		Tab tab = new Tab(remoteLog.getName());
		tab.setClosable(false);
		tabs.getTabs().add(tab);
	}
	if(tabs.getTabs().size() > 0){
		tabs.getSelectionModel().select(0);
		selectLog(0);
	}
	tabs.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>(){
		@Override
		public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
			selectLog(newValue.intValue());
		}
	});
	root.setTop(tabs);
	
	
	return new Scene(root, 450, 300);
}
 
Example 30
Project: javafx-qiniu-tinypng-client   File: ObservableRules.java   Source Code and License 5 votes vote down vote up
public static ObservableBooleanValue notEmpty(ObservableValue<String> source) {
	return Bindings.createBooleanBinding(() -> {
		final String s = source.getValue();
		
		return s != null && !s.trim().isEmpty();
	}, source);
}
 
Example 31
Project: CNU_TermProject_SoftwareEngineering   File: ItemManagementController.java   Source Code and License 5 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
    backBtn.setOnAction(this::backButtonAction);
    registerBtn.setOnAction(this::registerButtonAction);
    modifyBtn.setOnAction(this::modifyButtonAction);
    deleteBtn.setOnAction(this::deleteButtonAction);
    itemName.setCellValueFactory(cellData -> cellData.getValue().itemNameProperty());
    category.setCellValueFactory(cellData -> cellData.getValue().categoryProperty());
    price.setCellValueFactory(cellData -> cellData.getValue().priceProperty().asObject());
    itemListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TableRowDataModel>() {
        @Override
        public void changed(ObservableValue<? extends TableRowDataModel> observable, TableRowDataModel oldValue, TableRowDataModel newValue) {
            if (itemList.isEmpty())
                return;
            TableRowDataModel model = itemListView.getSelectionModel().getSelectedItem();
            System.out.println(model.itemName);
            System.out.println(model.price);
            System.out.println(model.category);
            ItemNameTF.setText(String.valueOf(model.itemName.getValue()));
            PriceBox.setText(String.valueOf(model.price.getValue()));
            ChoiceCategory.getSelectionModel().select(categoryList.indexOf(model.category.getValue()));
        }
    });
    loadCategoryList();
    loadItemList();
    itemListView.getSelectionModel().selectFirst();
}
 
Example 32
Project: marathonv5   File: TextValidatorSample.java   Source Code and License 5 votes vote down vote up
public TextInputValidatorPane() {
    contentProperty().addListener(new ChangeListener<C>() {                
        @Override public void changed(ObservableValue<? extends C> ov, C oldValue, C newValue) {
            if (oldValue != null) oldValue.textProperty().removeListener(textListener);
            if (newValue != null) newValue.textProperty().addListener(textListener);
        }
    });
}
 
Example 33
Project: Coconut-IDE   File: CreateProjectPresenter.java   Source Code and License 5 votes vote down vote up
private void computePropertyProjectName(ObservableValue<? extends String> observable, String oldValue, String newValue) {
    if (!wasChanged && pathStartsWithPathOfProjects()) {
        projectPath.setText(projects.getCorePathString() + newValue);
        wasChanged = false;
    } else {
        wasChanged = true;
    }
}
 
Example 34
Project: marathonv5   File: ToggleButtonSample.java   Source Code and License 5 votes vote down vote up
public ToggleButtonSample() {
    // create label to show result of selected toggle button
    final Label label = new Label();
    label.setStyle("-fx-font-size: 2em;");
    // create 3 toggle buttons and a toogle group for them
    final ToggleButton tb1 = new ToggleButton("Cat");
    final ToggleButton tb2 = new ToggleButton("Dog");
    final ToggleButton tb3 = new ToggleButton("Horse");
    ToggleGroup group = new ToggleGroup();
    tb1.setToggleGroup(group);
    tb2.setToggleGroup(group);
    tb3.setToggleGroup(group);
    group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle selectedToggle) {
            if(selectedToggle!=null) {
                label.setText(((ToggleButton) selectedToggle).getText());
            }
            else {
                label.setText("...");
            }
        }
    });
    // select the first button to start with
    group.selectToggle(tb1);
    // add buttons and label to grid and set their positions
    GridPane.setConstraints(tb1,0,0);
    GridPane.setConstraints(tb2,1,0);
    GridPane.setConstraints(tb3,2,0);
    GridPane.setConstraints(label,0,1,3,1);
    GridPane grid = new GridPane();
    grid.setVgap(20);
    grid.setHgap(10);
    getChildren().add(grid);
    grid.getChildren().addAll(tb1, tb2, tb3, label);
}
 
Example 35
Project: ABC-List   File: TopicPresenter.java   Source Code and License 5 votes vote down vote up
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
    if (
            topic != null
            && !topic.isMarkAsChanged()
    ) { 
        topic.setMarkAsChanged(Boolean.TRUE);
    }
}
 
Example 36
Project: WebPLP   File: OnLoadListener.java   Source Code and License 5 votes vote down vote up
public void changed(ObservableValue<? extends State> value, State oldState,
		State newState)
{
	if (newState == State.SUCCEEDED)
	{
		onLoadFunction.perform();
		
		if (observable != null)
			observable.removeListener(this);
	}
}
 
Example 37
Project: marathonv5   File: HyperlinkRedirectListener.java   Source Code and License 5 votes vote down vote up
@Override public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
    if (State.SUCCEEDED.equals(newValue)) {
        Document document = webView.getEngine().getDocument();
        NodeList anchors = document.getElementsByTagName(ANCHOR_TAG);
        for (int i = 0; i < anchors.getLength(); i++) {
            Node node = anchors.item(i);
            EventTarget eventTarget = (EventTarget) node;
            eventTarget.addEventListener(CLICK_EVENT, this, false);
        }
    }
}
 
Example 38
Project: JavaFX-EX   File: BeanUtil.java   Source Code and License 5 votes vote down vote up
public static <F, T> ListProperty<T> nestListProp(ObservableValue<F> pf, Function<F, ListProperty<T>> func) {
  ListProperty<T> current = func.apply(pf.getValue());
  ListProperty<T> nestProp = new SimpleListProperty<>();
  CacheUtil.set(BeanUtil.class, nestProp, current);
  nestProp.bindBidirectional(current);
  pf.addListener((ob, o, n) -> {
    CacheUtil.<ListProperty<T>> remove(BeanUtil.class, nestProp).ifPresent(p -> nestProp.unbindContentBidirectional(p));
    ListProperty<T> pt = func.apply(n);
    CacheUtil.set(BeanUtil.class, nestProp, pt);
    nestProp.bindContentBidirectional(pt);
  });
  return nestProp;
}
 
Example 39
Project: CBM-Changes-Explorer   File: Controller.java   Source Code and License 5 votes vote down vote up
@Override
public void changed(ObservableValue<? extends String> observable, String oldId, String newId) {
  if (null == newId) return;

  Map properties = db.getDocument(newId).getProperties();

  try {
    String json = mapper.writeValueAsString(properties);

    contentsText.setText(prettyText(json));
  } catch (JsonProcessingException ex) {
    ex.printStackTrace();
    Dialog.display(ex);
  }
}
 
Example 40
Project: alchem   File: InventoryController.java   Source Code and License 5 votes vote down vote up
public void onChangingSearchOption() {
    searchGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue<? extends Toggle> ov,
                            Toggle old_toggle, Toggle new_toggle) {
            if (searchGroup.getSelectedToggle() != null) {
                searchField.setText("");
            }
        }
    });

}
 
Example 41
Project: marathonv5   File: JavaFXCheckBoxTableCellElement.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public String _getValue() {
    CheckBoxTableCell cell = (CheckBoxTableCell) node;
    Callback selectedStateCallback = cell.getSelectedStateCallback();
    String cbText;
    if (selectedStateCallback != null) {
        ObservableValue<Boolean> call = (ObservableValue<Boolean>) selectedStateCallback.call(cell.getItem());
        int selection = call.getValue() ? 2 : 0;
        cbText = JavaFXCheckBoxElement.states[selection];
    } else {
        Node cb = cell.getGraphic();
        JavaFXElement comp = (JavaFXElement) JavaFXElementFactory.createElement(cb, driver, window);
        cbText = comp._getValue();

    }
    String cellText = cell.getText();
    if (cellText == null) {
        cellText = "";
    }
    String text = cellText + ":" + cbText;
    return text;
}
 
Example 42
Project: CSS-Editor-FX   File: SearchBar.java   Source Code and License 5 votes vote down vote up
public SearchBar(ObservableValue<CodeArea> codeArea) {
  super();
  this.codeArea = codeArea;
  this.showing = new SimpleBooleanProperty(false);
  initUI();
  initBind();
}
 
Example 43
Project: marathonv5   File: SimplePropertySheet.java   Source Code and License 5 votes vote down vote up
public static Object get(ObservableValue valueModel) {
    if (valueModel instanceof DoubleProperty) {
        return ((DoubleProperty)valueModel).get();
    } else if (valueModel instanceof ObjectProperty) {
        return ((ObjectProperty)valueModel).get();
    }

    return null;
}
 
Example 44
Project: marathonv5   File: SimplePropertySheet.java   Source Code and License 5 votes vote down vote up
public static void set(ObservableValue valueModel, Object value) {
    if (valueModel instanceof DoubleProperty) {
        ((DoubleProperty)valueModel).set((Double)value);
    } else if (valueModel instanceof ObjectProperty) {
        ((ObjectProperty)valueModel).set(value);
    }
}
 
Example 45
Project: marathonv5   File: ToggleButtonSample.java   Source Code and License 5 votes vote down vote up
public ToggleButtonSample() {
    // create label to show result of selected toggle button
    final Label label = new Label();
    label.setStyle("-fx-font-size: 2em;");
    // create 3 toggle buttons and a toogle group for them
    final ToggleButton tb1 = new ToggleButton("Cat");
    final ToggleButton tb2 = new ToggleButton("Dog");
    final ToggleButton tb3 = new ToggleButton("Horse");
    ToggleGroup group = new ToggleGroup();
    tb1.setToggleGroup(group);
    tb2.setToggleGroup(group);
    tb3.setToggleGroup(group);
    group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle selectedToggle) {
            if(selectedToggle!=null) {
                label.setText(((ToggleButton) selectedToggle).getText());
            }
            else {
                label.setText("...");
            }
        }
    });
    // select the first button to start with
    group.selectToggle(tb1);
    // add buttons and label to grid and set their positions
    GridPane.setConstraints(tb1,0,0);
    GridPane.setConstraints(tb2,1,0);
    GridPane.setConstraints(tb3,2,0);
    GridPane.setConstraints(label,0,1,3,1);
    GridPane grid = new GridPane();
    grid.setVgap(20);
    grid.setHgap(10);
    getChildren().add(grid);
    grid.getChildren().addAll(tb1, tb2, tb3, label);
}
 
Example 46
Project: can4eve   File: TestAppGUI.java   Source Code and License 5 votes vote down vote up
@Test
public void testTabIcons() throws Exception {
  JavaFXDisplay display = super.getDisplay();
  VBox vbox = new VBox();
  display.setRoot(vbox);
  SampleApp sampleApp = new SampleApp("menus", vbox);
  sampleApp.show();
  sampleApp.waitOpen();
  display.setStage(sampleApp.getStage());
  Platform.runLater(() -> {
    MenuBar menuBar = display.createMenuBar(sampleApp.getScene(),
        display.getApp());
    display.setMenuBar(menuBar);
    display.showMenuBar(sampleApp.getScene(), menuBar, true);
    display.setUpStatusBar();
  });
  XYTabPane xyTabPane = display.getXyTabPane();
  Platform.runLater(() -> {
    display.setupXyTabPane();
    display.setupDashBoard();
  });
  // xyTabPane.prefHeightProperty().bind(display.getStage().heightProperty());
  display.getStage().heightProperty()
      .addListener(new ChangeListener<Number>() {

        @Override
        public void changed(ObservableValue<? extends Number> observable,
            Number oldValue, Number newValue) {
          if (xyTabPane != null)
            System.out.println("oldh: " + oldValue.intValue() + " newh: "
                + newValue.intValue() + " xyh:" + xyTabPane.getPrefHeight()
                + " vth:" + xyTabPane.getvTabPane().getPrefHeight());
        }
      });
  Thread.sleep(SHOW_TIME);
  sampleApp.close();
}
 
Example 47
Project: marathonv5   File: TooltipSample.java   Source Code and License 5 votes vote down vote up
@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Tooltip Sample");
    stage.setWidth(330);
    stage.setHeight(150);

    total.setFont(new Font("Arial", 20));
    
    for (int i = 0; i < rooms.length; i++) {
        final CheckBox cb = cbs[i] = new CheckBox(rooms[i]);
        final Integer rate = rates[i];
        final Tooltip tooltip = new Tooltip("$" + rates[i].toString());
        tooltip.setFont(new Font("Arial", 16));
        cb.setTooltip(tooltip);
 cb.selectedProperty().addListener(
            (ObservableValue<? extends Boolean> ov, Boolean old_val, 
            Boolean new_val) -> {
                if (cb.isSelected()) {
                    sum = sum + rate;
                } else {
                    sum = sum - rate;
                }
                total.setText("Total: $" + sum.toString());
            }
        );
    }

    VBox vbox = new VBox();
    vbox.getChildren().addAll(cbs);
    vbox.setSpacing(5);
    HBox root = new HBox();
    root.getChildren().add(vbox);
    root.getChildren().add(total);
    root.setSpacing(40);
    root.setPadding(new Insets(20, 10, 10, 20));

    ((Group) scene.getRoot()).getChildren().add(root);

    stage.setScene(scene);
    stage.show();
}
 
Example 48
Project: Dr-Assistant   File: SettingController.java   Source Code and License 5 votes vote down vote up
/**
 * Initializes the controller class.
 *
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    tfUserName.textProperty().addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> {
        if (!newValue.isEmpty()) {
            if (!newValue.matches("^[^\\d\\s]+$")) {
                tfUserName.setText(oldValue);
            }
        }
    });

    Platform.runLater(() -> {
        loadAuthUser();
    });
}
 
Example 49
Project: SQLNavigator   File: SQLNavigator.java   Source Code and License 5 votes vote down vote up
public void createScene() {
    Platform.runLater(()->{
        WebView view = new WebView();
        engine = view.getEngine();
        FXPanel.setScene(new Scene(view));
        engine.load(url+"SQLNavigator/Import/Import.html");
        engine.getLoadWorker().stateProperty().addListener((ObservableValue<? extends Worker.State> ov,Worker.State oldState, Worker.State newState) -> {  
                        if (newState == Worker.State.SUCCEEDED) {
                            //engine.executeScript("if (!document.getElementById('FirebugLite')){E = document['createElement' + 'NS'] && document.documentElement.namespaceURI;E = E ? document['createElement' + 'NS'](E, 'script') : document['createElement']('script');E['setAttribute']('id', 'FirebugLite');E['setAttribute']('src', 'https://getfirebug.com/' + 'firebug-lite.js' + '#startOpened');E['setAttribute']('FirebugLite', '4');(document['getElementsByTagName']('head')[0] || document['getElementsByTagName']('body')[0]).appendChild(E);E = new Image;E['setAttribute']('src', 'https://getfirebug.com/' + '#startOpened');}");
                            JSObject win =  (JSObject) engine.executeScript("window");
                            win.setMember("SQL",exec);
                        }
                    }
            );
        engine.titleProperty().addListener(new javafx.beans.value.ChangeListener<String>() {
                @Override
                public void changed(ObservableValue<? extends String> observable, String oldValue, final String newValue) {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            ImportTool.this.setTitle(newValue);
                        }
                    });
                }
            });
    });
}
 
Example 50
Project: marathonv5   File: MenuSample.java   Source Code and License 5 votes vote down vote up
private static CheckMenuItem createMenuItem (String title, final Node node){
    CheckMenuItem cmi = new CheckMenuItem(title);
    cmi.setSelected(true);
    cmi.selectedProperty().addListener(
        (ObservableValue<? extends Boolean> ov, Boolean old_val, 
        Boolean new_val) -> {
            node.setVisible(new_val);
    });              
    return cmi;
}
 
Example 51
Project: springfx   File: FirstPresentation.java   Source Code and License 5 votes vote down vote up
@FXML
void initialize() {
    if (Language.RO.equals(langCtr.getLanguage())) {
        engRadio.setSelected(false);
        romRadio.setSelected(true);
    }
    langGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) {
            changeLanguage();
        }
    });
}
 
Example 52
Project: marathonv5   File: ScrollBarSample.java   Source Code and License 5 votes vote down vote up
@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 180, 180);
    scene.setFill(Color.BLACK);
    stage.setScene(scene);
    stage.setTitle("Scrollbar");
    root.getChildren().addAll(vb, sc);

    shadow.setColor(Color.GREY);
    shadow.setOffsetX(2);
    shadow.setOffsetY(2);

    vb.setLayoutX(5);
    vb.setSpacing(10);

    sc.setLayoutX(scene.getWidth()-sc.getWidth());
    sc.setMin(0);
    sc.setOrientation(Orientation.VERTICAL);
    sc.setPrefHeight(180);
    sc.setMax(360);

    for (int i = 0; i < 5; i++) {
        final Image image = images[i] =
            new Image(getClass().getResourceAsStream("fw" +(i+1)+ ".jpg"));
        final ImageView pic = pics[i] =
            new ImageView(images[i]);
        pic.setEffect(shadow);
        vb.getChildren().add(pics[i]);
    }
    
  

  sc.valueProperty().addListener((ObservableValue<? extends Number> ov, 
        Number old_val, Number new_val) -> {
            vb.setLayoutY(-new_val.doubleValue());
    });  

    stage.show();
}
 
Example 53
Project: marathonv5   File: ScrollPaneSample.java   Source Code and License 5 votes vote down vote up
@Override
public void start(Stage stage) {
    VBox box = new VBox();
    Scene scene = new Scene(box, 180, 180);
    stage.setScene(scene);
    stage.setTitle("ScrollPaneSample");
    box.getChildren().addAll(sp, fileName);
    VBox.setVgrow(sp, Priority.ALWAYS);

    fileName.setLayoutX(30);
    fileName.setLayoutY(160);
    
    Image roses = new Image(getClass().getResourceAsStream("roses.jpg"));
    sp.setContent(new ImageView(roses));
    sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    
    
    
    for (int i = 0; i < 5; i++) {
        images[i] = new Image(getClass().getResourceAsStream(imageNames[i]));
        pics[i] = new ImageView(images[i]);
        pics[i].setFitWidth(100);
        pics[i].setPreserveRatio(true);
        vb.getChildren().add(pics[i]);
    }

    sp.setVmax(440);
    sp.setPrefSize(115, 150);
    sp.setContent(vb);
    sp.vvalueProperty().addListener((ObservableValue<? extends Number> ov, 
        Number old_val, Number new_val) -> {
            fileName.setText(imageNames[(new_val.intValue() - 1)/100]);
    });
    stage.show();
}
 
Example 54
Project: jedai-ui   File: ConfirmController.java   Source Code and License 5 votes vote down vote up
/**
 * Create a Label whose value is bound to an observable value.
 *
 * @param observable Value to bind to label text
 * @return Label with bound value
 */
private Label boundLabel(ObservableValue<? extends String> observable) {
    // Create label
    Label l = new Label();

    // Bind its value to the observable
    l.textProperty().bind(observable);

    return l;
}
 
Example 55
Project: JHosts   File: HostController.java   Source Code and License 5 votes vote down vote up
private <T> void setupCellValueFactory(JFXTreeTableColumn<FXHost, T> column, Function<FXHost, ObservableValue<T>> mapper) {
    column.setCellValueFactory((TreeTableColumn.CellDataFeatures<FXHost, T> param) -> {
        if (column.validateValue(param)) {
            return mapper.apply(param.getValue().getValue());
        } else {
            return column.getComputedValue(param);
        }
    });
}
 
Example 56
Project: ABC-List   File: CheckBoxListCell.java   Source Code and License 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void updateItem(T item, boolean empty) {
    super.updateItem(item, empty);
    
    if (! empty) {
        StringConverter<T> c = getConverter();
        Callback<T, ObservableValue<Boolean>> callback = getSelectedStateCallback();
        if (callback == null) {
            throw new NullPointerException(
                    "The CheckBoxListCell selectedStateCallbackProperty can not be null");
        }
        
        setGraphic(checkBox);
        setText(c != null ? c.toString(item) : (item == null ? "" : item.toString()));
        
        if (booleanProperty != null) {
            checkBox.selectedProperty().unbindBidirectional((BooleanProperty)booleanProperty);
        }
        booleanProperty = callback.call(item);
        if (booleanProperty != null) {
            checkBox.selectedProperty().bindBidirectional((BooleanProperty)booleanProperty);
        }
    } else {
        setGraphic(null);
        setText(null);
    }
}
 
Example 57
Project: uPMT   File: MomentExpVBox.java   Source Code and License 5 votes vote down vote up
private void editNameMode() {
	TextField t = new TextField();
	t.setMaxWidth(180);
	t.setText(moment.getNom());
	t.requestFocus();
	
	ChangeListener<Boolean>	 listener = new ChangeListener<Boolean>() {
		 @Override
		    public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue)
		    {
		        if (!newPropertyValue)
		        {
		        	RenameMomentCommand cmd = new RenameMomentCommand(nameController,moment.getNom(),t.getText());
					cmd.execute();
					UndoCollector.INSTANCE.add(cmd);
					borderPaneLabel.setCenter(label);
					t.focusedProperty().removeListener(this);
		        }
		    }
	};
	t.setOnKeyPressed(new EventHandler<KeyEvent>() {

		@Override
		public void handle(KeyEvent event) {
			if(event.getCode() == KeyCode.ENTER){
				t.setText(t.getText());
				borderPaneLabel.setCenter(label);
			}
			if(event.getCode() == KeyCode.ESCAPE){
				borderPaneLabel.setCenter(label);
			}
		}
	});
	t.focusedProperty().addListener(listener);
	Platform.runLater(()->t.requestFocus());
	Platform.runLater(()->t.selectAll());
	borderPaneLabel.setCenter(t);
}
 
Example 58
Project: OftenPorter   File: SliderBinder.java   Source Code and License 5 votes vote down vote up
public SliderBinder(Slider view)
{
    super(view);
    changeListener = new ChangeListener<Number>()
    {
        @Override
        public synchronized void changed(ObservableValue<? extends Number> observable, Number oldValue,
                Number newValue)
        {
            doOnchange(oldValue,newValue);
        }
    };
    view.valueProperty().addListener(changeListener);
}
 
Example 59
Project: Dayflower-Path-Tracer   File: TestApplication.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings("unused")
private void doOnSliderYaw(final ObservableValue<? extends Number> observableValue, final Number oldValue, final Number newValue) {
	this.camera.setYaw(Angle.degrees(newValue.floatValue()));
}
 
Example 60
Project: can4eve   File: JFXTripletDisplay.java   Source Code and License 4 votes vote down vote up
/**
 * setup the special parts e.g. history
 * 
 * @param cpm
 * @throws Exception
 */
@SuppressWarnings({ "rawtypes" })
public void setupSpecial(CANPropertyManager cpm) throws Exception {
  // resetButton handling for trip Odometer
  CANProperty<DoubleValue, Double> tripOdoValue = cpm.get("TripOdo");
  tripOdoValue.getProperty().addListener(new ChangeListener<Number>() {

    @Override
    public void changed(ObservableValue<? extends Number> observable,
        Number oldValue, Number newValue) {
      if (newValue.equals(0.0)) {
        CANProperty<DoubleValue, Double> tripRounds = cpm.get("TripRounds");
        Date timeStamp = new Date();
        tripRounds.getCanValue().setValue(0.0, timeStamp);
      }
    }

  });
  TabPane tabPane = super.getXyTabPane().getTabPane(BATTERY_GROUP);
  if (tabPane != null) {
    CANProperty<DoubleValue, Double> cellTemperature = cpm
        .get("CellTemperature");
    final JFXCanCellStatePlot cellStatePlot = new JFXCanCellStatePlot(
        "cellTemperature", "cell", "Temperature", cellTemperature, 1.0, 0.5);

    Platform.runLater(() -> super.getXyTabPane().addTab(tabPane, "cellTemp",
        I18n.get(I18n.CELL_TEMP), "temp50", cellStatePlot.getBarChart()));
    cellStatePlot.updateOn(cellTemperature.getUpdateCountProperty());

    CANProperty<DoubleValue, Double> cellVoltage = cpm.get("CellVoltage");
    final JFXCanCellStatePlot cellVoltagePlot = new JFXCanCellStatePlot(
        "cellVoltage", "cell", "Voltage", cellVoltage, 0.01, 0.1);
    Platform.runLater(() -> super.getXyTabPane().addTab(tabPane,
        "cellVoltage", I18n.get(I18n.CELL_VOLTAGE),
        FontAwesome.Glyph.FLASH.name(), cellVoltagePlot.getBarChart()));
    cellVoltagePlot.updateOn(cellVoltage.getUpdateCountProperty());

    // setup history
    String title = "SOC/RR";
    String xTitle = "time";
    String yTitle = "%/km";
    Map<String, CANProperty> properties = cpm.getCANProperties("SOC",
        "Range");
    final JFXCanValueHistoryPlot valuePlot = new JFXCanValueHistoryPlot(title,
        xTitle, yTitle, properties);
    // TODO - use addTab and remove from the json app declaration file
    Platform.runLater(() -> updateTab("soc_rr", valuePlot.createLineChart()));
    valuePlot.updateOn(cpm.get("SOC").getUpdateCountProperty());
  }
}