本文整理汇总了Java中javafx.beans.value.ChangeListener.changed方法的典型用法代码示例。如果您正苦于以下问题:Java ChangeListener.changed方法的具体用法?Java ChangeListener.changed怎么用?Java ChangeListener.changed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.beans.value.ChangeListener
的用法示例。
在下文中一共展示了ChangeListener.changed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: EditableText
import javafx.beans.value.ChangeListener; //导入方法依赖的package包/类
public EditableText(double positionX, double positionY) {
super();
text.getStyleClass().add("state-text");
text.setEditable(false);
ChangeListener updater = (observable, oldValue, newValue) -> {
text.setPrefWidth(getWidth());
text.setPrefHeight(getHeight());
relocate(
positionX - getWidth()/2,
positionY - getHeight()/2
);
mask.setPrefWidth(getWidth());
mask.setPrefHeight(getHeight());
};
widthProperty().addListener(updater);
heightProperty().addListener(updater);
updater.changed(null, null, null);
mask.getStyleClass().add("state-text-mask");
this.getChildren().add(text);
this.getChildren().add(mask);
}
示例3: IndexTableCell
import javafx.beans.value.ChangeListener; //导入方法依赖的package包/类
/**
* IndexTableCell
* @param tableView the table the index-cell should be attached to. This value is required for
* displaying the comment icon.
*/
public IndexTableCell(TableView tableView) {
super();
this.tableView = tableView;
ChangeListener<Number> indexChangeListener = (observableValue, oldIndex, newIndexNumber) -> {
int newIndex = newIndexNumber.intValue();
if (newIndex < 0) {
return;
}
icon.visibleProperty().bind(getCommentPropertyByIndex(newIndex).isEmpty().not());
tooltip.textProperty().bind(getCommentPropertyByIndex(newIndex));
};
indexChangeListener.changed(null, 0, this.getIndex());
this.indexProperty().addListener(indexChangeListener);
this.setGraphic(icon);
this.setTextAlignment(TextAlignment.RIGHT);
this.setTooltip(tooltip);
}
示例4: createStretchingImagePane
import javafx.beans.value.ChangeListener; //导入方法依赖的package包/类
public static StackPane createStretchingImagePane(final String image, final Scene scene)
{
// the amount of work required to emulate the GinENGINE background scaler was quite excessive :/
final ImageView backgroundImageView = new ImageView(JavaFxHelper.buildResourcePath(image));
final double bgWidth = backgroundImageView.getImage().getWidth();
final double bgHeight = backgroundImageView.getImage().getHeight();
final SimpleDoubleProperty scaledWidth = new SimpleDoubleProperty();
final SimpleDoubleProperty scaledHeight = new SimpleDoubleProperty();
ChangeListener<? super Number> chl = new ChangeListener<Number>()
{
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue)
{
double scalingFactor = Math.max((scene.widthProperty().get() / bgWidth), (scene.heightProperty().get() / bgHeight));
scaledWidth.set(bgWidth * scalingFactor);
scaledHeight.set(bgHeight * scalingFactor);
}
};
scene.widthProperty().addListener(chl);
scene.heightProperty().addListener(chl);
chl.changed(null, null, null);
backgroundImageView.setPreserveRatio(true);
backgroundImageView.fitWidthProperty().bind(scaledWidth);
backgroundImageView.fitHeightProperty().bind(scaledHeight);
StackPane backgroundImageStack = new StackPane();
backgroundImageStack.getChildren().add(backgroundImageView);
return backgroundImageStack;
}
示例5: init
import javafx.beans.value.ChangeListener; //导入方法依赖的package包/类
private void init() {
setHgap(GuiConstants.padding);
setVgap(GuiConstants.padding);
InetSocketAddress address = config.getUidAddress();
add(new Label("Host:"), 0, 0);
hostField = new TextField(address != null ? address.getHostString() : "");
add(hostField, 1, 0);
add(new Label("Port:"), 0, 1);
portField = new TextField(address != null ? Integer.toString(address.getPort()) : "");
add(portField, 1, 1);
add(new Label("User:"), 0, 2);
userField = new TextField(config.getUidUser() != null ? config.getUidUser() : "");
add(userField, 1, 2);
add(new Label("Password:"), 0, 3);
passwordField = new TextField(config.getUidPassword() != null ? config.getUidPassword() : "");
add(passwordField, 1, 3);
add(new Label("Project:"), 0, 4);
projectField = new TextField(config.getUidProject() != null ? config.getUidProject() : "");
add(projectField, 1, 4);
add(new Label("Version A:"), 0, 5);
versionAField = new TextField(config.getUidVersionA() != null ? config.getUidVersionA() : "");
add(versionAField, 1, 5);
add(new Label("Version B:"), 0, 6);
versionBField = new TextField(config.getUidVersionB() != null ? config.getUidVersionB() : "");
add(versionBField, 1, 6);
ChangeListener<String> changeListener = (observable, oldValue, newValue) -> {
int port;
okButton.setDisable(hostField.getText().isEmpty()
|| portField.getText().isEmpty()
|| !portField.getText().matches("\\d{1,5}")
|| (port = Integer.parseInt(portField.getText())) > 0xffff
|| port <= 0
|| userField.getText().isEmpty()
|| passwordField.getText().isEmpty()
|| projectField.getText().isEmpty()
|| versionAField.getText().isEmpty()
|| versionBField.getText().isEmpty());
};
hostField.textProperty().addListener(changeListener);
portField.textProperty().addListener(changeListener);
userField.textProperty().addListener(changeListener);
passwordField.textProperty().addListener(changeListener);
projectField.textProperty().addListener(changeListener);
versionAField.textProperty().addListener(changeListener);
versionBField.textProperty().addListener(changeListener);
changeListener.changed(null, null, null);
}