本文整理汇总了Java中javafx.beans.value.ChangeListener类的典型用法代码示例。如果您正苦于以下问题:Java ChangeListener类的具体用法?Java ChangeListener怎么用?Java ChangeListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChangeListener类属于javafx.beans.value包,在下文中一共展示了ChangeListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SearchBox
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
public SearchBox() {
setId("SearchBox");
getStyleClass().add("search-box");
setMinHeight(24);
setPrefSize(200, 24);
setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
textBox = new TextField();
textBox.setPromptText("Search");
clearButton = new Button();
clearButton.setVisible(false);
getChildren().addAll(textBox, clearButton);
clearButton.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent actionEvent) {
textBox.setText("");
textBox.requestFocus();
}
});
textBox.textProperty().addListener(new ChangeListener<String>() {
@Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
clearButton.setVisible(textBox.getText().length() != 0);
}
});
}
示例2: IWURLField
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
public IWURLField(WebView webView, boolean secured, Tab tab) {
this.webView = webView;
this.tab = tab;
this.securedHTTP = secured;
setText(IWPropertyHelper.getProperty("default_homepage"));
webView.getEngine().getLoadWorker().stateProperty().addListener(
new ChangeListener<State>() {
@Override
public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
if (newValue == State.SUCCEEDED) {
tab.setText(webView.getEngine().getTitle());
}
if (newValue == State.FAILED) {
if(getText().toString().equals("")) {
webView.getEngine().loadContent("<html><title>Empty Tab</title><body></body></html>");
} else {
webView.getEngine().loadContent("<html><title>Oops!</title><body><b>Page not found!</b></body></html>");
}
}
}
});
}
示例3: MenuItemBinder
import javafx.beans.value.ChangeListener; //导入依赖的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: initSpinners
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
private void initSpinners() {
ChangeListener<Integer> listener = (observable, oldValue, newValue) -> {
int sup = suppliers.getValue();
int rec = recipients.getValue();
restoreMatrix(transport,sup,rec,true);
restoreMatrix(result,sup,rec, false);
restoreVector(capability,sup,true);
restoreVector(production,sup, true);
restoreVector(storage,sup, true);
restoreVector(excess,sup, false);
restoreVector(demand,rec, true);
};
suppliers.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1,6,1,1));
recipients.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1,10,1,1));
suppliers.valueProperty().addListener(listener);
recipients.valueProperty().addListener(listener);
listener.changed(null,null,null);
}
示例5: showHisoty
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
private void showHisoty() {
debug = new HistorySearch(cmboHistoryMonth.getValue(), cmboFilterList.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("HistorySearch", debug); // insert object
windowObject.call("ready"); // execute callback
}
}
}
);
URL url = getClass().getResource("/html/index.html");
webEngine.load(url.toString());
}
示例6: initializeExpressionsSortFilterChoiceBox
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
private void initializeExpressionsSortFilterChoiceBox() {
expressionSorterChoiceBox.setItems(FXCollections.observableArrayList(ExpressionSortOrder.values()));
expressionSorterChoiceBox.getSelectionModel().select(expressionSortOrder);
expressionSorterChoiceBox.setConverter(new StringConverter<ExpressionSortOrder>() {
@Override
public String toString(ExpressionSortOrder object) {
return object.getDisplayName();
}
@Override
public ExpressionSortOrder fromString(String string) {
return null;
}
});
expressionSorterChoiceBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ExpressionSortOrder>() {
@Override
public void changed(ObservableValue observable, ExpressionSortOrder oldValue, ExpressionSortOrder newValue) {
expressionSortOrder = newValue;
populateExpressionsListView();
}
});
}
示例7: bind
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
public void bind(Dialog<?> dialog) {
if (map.containsKey(dialog)) {
return;
}
ChangeListener<? super SkinStyle> listener = (ob, o, n) -> {
dialog.getDialogPane().getStylesheets().remove(o.getURL());
dialog.getDialogPane().getStylesheets().add(n.getURL());
};
if (skin.get() != null) {
dialog.getDialogPane().getStylesheets().add(skin.get().getURL());
}
skin.addListener(listener);
map.put(dialog, listener);
dialog.setOnHidden(e -> {
skin.removeListener(listener);
map.remove(dialog);
});
}
示例8: expanderListener
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
public ChangeListener<Boolean> expanderListener() {
return (observable, oldValue, newValue) -> {
BooleanProperty bb = (BooleanProperty) observable;
TreeItem t = (TreeItem) bb.getBean();
CustomIcons customIcons = new CustomIcons();
t.setGraphic(new ImageView(newValue ? customIcons.getFolderExpandImage() : customIcons.getFolderCollapseImage()));
if (newValue) {
scheduleHighlight();
}
};
}
示例9: WebViewPane
import javafx.beans.value.ChangeListener; //导入依赖的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);
}
示例10: addAvatarListener
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
public void addAvatarListener(ChangeListener<? super Image> listener, int size) {
//synchronized (avatarLock) {
avatarListeners.add(listener);
avatarWanted = true;
if (size > avatarSize) {
avatarSize = size;
}
try {
updateAvatar();
} catch (RestfulHTTPException | IOException e) {
System.out.printf("Failed to load image %s%n", e.getMessage());
}
avatar.addListener(listener);
//}
}
示例11: makeLocationScale
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
private static void makeLocationScale(Scene scene, Node node) {
double nodeX = node.getLayoutX();
double sceneWidth = scene.getWidth();
double nodeY = node.getLayoutY();
double sceneHeight = scene.getHeight();
if (nodeX != 0.0) {
ChangeListener<Number> xResizer = (arg0, oldValue, newValue) -> node.relocate(nodeX / sceneWidth * newValue.doubleValue(), node.getLayoutY());
scene.widthProperty().addListener(xResizer);
}
if (nodeY != 0.0) {
ChangeListener<Number> yResizer = (arg0, oldValue, newValue) -> node.relocate(node.getLayoutX(), nodeY / sceneHeight * newValue.doubleValue());
scene.heightProperty().addListener(yResizer);
}
}
示例12: initialize
import javafx.beans.value.ChangeListener; //导入依赖的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);
}
});
}
示例13: createView
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
private void createView() {
webView = new WebView();
webView.setContextMenuEnabled(false);
webEngine = webView.getEngine();
webEngine.documentProperty().addListener(new ChangeListener<Document>() {
@Override
public void changed(ObservableValue<? extends Document> prop, Document oldDoc, Document newDoc) {
logger.debug("WebView loaded dataviewer with id : [{}]", udID);
if (enableFireBug)
enableFirebug(webEngine);
}
});
String urlToLoad = getUrlToLoad() + udID;
logger.debug("Loading: [{}]", urlToLoad);
webEngine.load(urlToLoad);
setStyle("-fx-background-color: white;");
setCenter(webView);
setTop(topMenu = new TopMenu(plotData, latestConfig, this));
}
示例14: getDocsInBackground
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
public void getDocsInBackground(final boolean showProxyDialogOnFail, final Runnable callBackOnSuccess) {
final FetchDocListTask task = new FetchDocListTask(Ensemble2.getEnsemble2().getDocsUrl());
task.stateProperty().addListener(new ChangeListener<Worker.State>() {
public void changed(ObservableValue<? extends Worker.State> ov, Worker.State t, Worker.State newState) {
try {
Thread.sleep(5); //timing problem
} catch (InterruptedException ie) {
ie.printStackTrace();
}
if (newState == Worker.State.SUCCEEDED) {
// extract all the docs pages from the all classes page
DocsHelper.extractDocsPagesFromAllClassesPage(
(CategoryPage)Ensemble2.getEnsemble2().getPages().getDocs(),
task.getValue(),
Ensemble2.getEnsemble2().getDocsUrl());
// update docs pages cross links to samples
DocsHelper.syncDocPagesAndSamplePages(
(CategoryPage)Ensemble2.getEnsemble2().getPages().getSamples());
if (callBackOnSuccess != null) callBackOnSuccess.run();
} else if (newState == Worker.State.FAILED) {
if (showProxyDialogOnFail) {
Ensemble2.getEnsemble2().showProxyDialog();
}
}
}
});
new Thread(task).start();
}
示例15: memoryWatchResult
import javafx.beans.value.ChangeListener; //导入依赖的package包/类
@Subscribe
public void memoryWatchResult(MemWatchResponseEvent e) {
if (!e.isSuccess())
return;
long address = e.getWatchedAddress();
LongProperty value = e.getMemObject();
value.addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
watchedAddresses.refresh();
}
});
MemoryRow row = new MemoryRow(address, value);
memoryAddresses.add(row);
}