本文整理匯總了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());
}