本文整理汇总了Java中javafx.beans.value.ObservableValue类的典型用法代码示例。如果您正苦于以下问题:Java ObservableValue类的具体用法?Java ObservableValue怎么用?Java ObservableValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObservableValue类属于javafx.beans.value包,在下文中一共展示了ObservableValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CheckBoxListCell
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
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);
}
示例2: createTextField
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
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());
}
}
});
}
示例3: MenuItemBinder
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
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);
}
示例4: initialize
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
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));
}
}
);
}
示例5: initialize
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
/**
* 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);
}
});
}
示例6: btnGo
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
@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);
}
示例7: WebViewPane
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
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);
}
示例8: initialize
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
@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);
}
});
}
示例9: _getValue
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
@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;
}
示例10: mapString
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
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());
}
}
};
}
示例11: buildEyeTrackerConfigChooser
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
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;
}
示例12: tableColumns
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
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()));
}
}
});
}
}
示例13: TypedToggleGroup
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
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);
}
}
});
}
示例14: changed
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
@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);
// }
}
}
示例15: spectateGame
import javafx.beans.value.ObservableValue; //导入依赖的package包/类
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);
}