本文整理汇总了Java中javafx.beans.property.BooleanProperty.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java BooleanProperty.addListener方法的具体用法?Java BooleanProperty.addListener怎么用?Java BooleanProperty.addListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.beans.property.BooleanProperty
的用法示例。
在下文中一共展示了BooleanProperty.addListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setActions
import javafx.beans.property.BooleanProperty; //导入方法依赖的package包/类
/**
* Overrides the draggable's set action method to lisen for when
* you can drag a sprite or not
*
* @param source
*/
@Override
public void setActions (Node source) {
BooleanProperty canPlace = getProfilable().getCost().canPlace();
setDraggedOrNot(source, canPlace.get());
canPlace.addListener( (observable, oldValue, newValue) -> setDraggedOrNot(source,
newValue));
}
示例2: bind
import javafx.beans.property.BooleanProperty; //导入方法依赖的package包/类
public void bind(final BooleanProperty property, final String propertyName) {
String value = props.getProperty(propertyName);
if (value != null) {
property.set(Boolean.valueOf(value));
}
property.addListener(new InvalidationListener() {
@Override
public void invalidated(Observable o) {
props.setProperty(propertyName, property.getValue().toString());
}
});
}
示例3: setShowOnlineDatabase
import javafx.beans.property.BooleanProperty; //导入方法依赖的package包/类
@Override
public void setShowOnlineDatabase(BooleanProperty showOnlineDatabase) {
showOnlineDatabase.addListener((observable, oldValue, newValue) -> {
if (newValue == null) {
return;
}
manager.toggleDatabase(newValue);
});
}
示例4: setupValuePane
import javafx.beans.property.BooleanProperty; //导入方法依赖的package包/类
private Pane setupValuePane(Dimension<?> dimension, Label titleLabel, Pane contentPane) {
final HBox titlePane = new HBox();
final VBox valueVBox = new VBox();
final Node backValueGraphicNode = new ImageView(backValueGraphic);
final double buttonScale = 0.66;
backValueGraphicNode.setScaleX(1 / buttonScale);
backValueGraphicNode.setScaleY(1 / buttonScale);
final Button backValue = new Button("", backValueGraphicNode);
backValue.setOnAction((e) -> {
traceExplorer.backValue(dimension);
});
backValue.setScaleX(buttonScale);
backValue.setScaleY(buttonScale);
backValue.setDisable(!traceExplorer.canBackValue(dimension));
final Node stepValueGraphicNode = new ImageView(stepValueGraphic);
stepValueGraphicNode.setScaleX(1 / buttonScale);
stepValueGraphicNode.setScaleY(1 / buttonScale);
final Button stepValue = new Button("", stepValueGraphicNode);
stepValue.setOnAction((e) -> {
traceExplorer.stepValue(dimension);
});
stepValue.setDisable(!traceExplorer.canStepValue(dimension));
stepValue.setScaleX(buttonScale);
stepValue.setScaleY(buttonScale);
titlePane.setAlignment(Pos.CENTER_LEFT);
VBox.setMargin(titlePane, HALF_MARGIN_INSETS);
VBox.setMargin(contentPane, MARGIN_INSETS);
final CheckBox showValueCheckBox = new CheckBox();
showValueCheckBox.setScaleX(buttonScale);
showValueCheckBox.setScaleY(buttonScale);
boolean hide = traceExtractor.isDimensionIgnored(dimension);
if (hide) {
showValueCheckBox.setSelected(false);
} else {
showValueCheckBox.setSelected(true);
}
BooleanProperty sel = showValueCheckBox.selectedProperty();
backValue.visibleProperty().bind(sel);
stepValue.visibleProperty().bind(sel);
sel.addListener((v, o, n) -> {
if (o != n) {
traceExtractor.ignoreDimension(dimension, !n);
if (n) {
valueVBox.getChildren().add(contentPane);
} else {
valueVBox.getChildren().remove(contentPane);
}
sortValueLines();
}
});
titlePane.getChildren().addAll(showValueCheckBox, titleLabel, backValue, stepValue);
valueVBox.getChildren().add(titlePane);
if (!hide) {
valueVBox.getChildren().add(contentPane);
}
valuesLines.getChildren().add(valueVBox);
valueVBox.setUserData(dimension);
titleLabel.minWidthProperty().bind(valueTitleWidth);
titleLabel.widthProperty().addListener((v, o, n) -> {
if (n.doubleValue() > valueTitleWidth.get()) {
valueTitleWidth.set(n.doubleValue());
}
});
if (titleLabel.widthProperty().doubleValue() > valueTitleWidth.get()) {
valueTitleWidth.set(titleLabel.widthProperty().doubleValue());
}
return valueVBox;
}
示例5: initPropertyComponents
import javafx.beans.property.BooleanProperty; //导入方法依赖的package包/类
private void initPropertyComponents() {
// General Properties
sampPathTextField.setText(ClientPropertiesController.getPropertyAsString(Property.SAMP_PATH));
sampPathTextField.textProperty().addListener((__, ___, newValue) -> {
ClientPropertiesController.setProperty(Property.SAMP_PATH, newValue.trim());
});
setupCheckBox(saveLastViewCheckBox, Property.SAVE_LAST_VIEW);
languageComboBox.getItems().addAll(Language.values());
final Language toSelectLanguage = Language.getByShortcut(ClientPropertiesController.getPropertyAsString(Property.LANGUAGE)).get();
languageComboBox.getSelectionModel().select(toSelectLanguage);
languageComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldVal, newVal) -> {
final Locale locale = new Locale(newVal.getShortcut());
Client.lang = ResourceBundle.getBundle("com.msc.serverbrowser.localization.Lang", locale);
ClientPropertiesController.setProperty(Property.LANGUAGE, newVal.getShortcut());
Client.getInstance().reloadViewIfLoaded(View.SETTINGS);
});
// Connection Properties
// setupCheckBox(askForUsernameOnConnectCheckBox,
// Property.ASK_FOR_NAME_ON_CONNECT);
// Appearance Properties
setupCheckBox(darkThemeCheckBox, Property.USE_DARK_THEME);
darkThemeCheckBox.selectedProperty().addListener((__, ___, newValue) -> {
final Boolean saveLastViewOld = ClientPropertiesController.getPropertyAsBoolean(Property.SAVE_LAST_VIEW);
ClientPropertiesController.setProperty(Property.SAVE_LAST_VIEW, true);
ClientPropertiesController.setProperty(Property.LAST_VIEW, View.SETTINGS.getId());
Client.getInstance().applyTheme();
ClientPropertiesController.setProperty(Property.SAVE_LAST_VIEW, saveLastViewOld);
});
// Permission Properties
setupCheckBox(allowCloseSampCheckBox, Property.ALLOW_CLOSE_SAMP);
setupCheckBox(allowCloseGtaCheckBox, Property.ALLOW_CLOSE_GTA);
// Update Properties
setupCheckBox(showChangelogCheckBox, Property.CHANGELOG_ENABLED);
setupCheckBox(enableAutomaticUpdatesCheckBox, Property.AUTOMTAIC_UPDATES);
// Update Properties
setupCheckBox(allowCachingDownloadsCheckBox, Property.ALLOW_CACHING_DOWNLOADS);
// Adding a listener to disable the update button incase an update is ongoing
final BooleanProperty updatingProperty = Client.getInstance().updatingProperty;
updatingProperty.addListener((observable, oldVal, newVal) -> {
manualUpdateButton.setDisable(newVal);
});
manualUpdateButton.setDisable(updatingProperty.get());
}