本文整理汇总了Java中javafx.scene.Node.setDisable方法的典型用法代码示例。如果您正苦于以下问题:Java Node.setDisable方法的具体用法?Java Node.setDisable怎么用?Java Node.setDisable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.Node
的用法示例。
在下文中一共展示了Node.setDisable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupOkButton
import javafx.scene.Node; //导入方法依赖的package包/类
private void setupOkButton() {
ButtonType okButtonType = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE);
getDialogPane().getButtonTypes().add(okButtonType);
Node okButton = getDialogPane().lookupButton(okButtonType);
okButton.setDisable(true);
okButton.setId("ok-button");
okButton.disableProperty().bind(
taskNotCompleted()
.and(noTaskException())
.or(taskIsRunning())
);
}
示例2: generateDialog
import javafx.scene.Node; //导入方法依赖的package包/类
private void generateDialog(GoogleService t) {
Dialog<ArrayList<String>> dialog = new Dialog<>();
dialog.setWidth(300);
dialog.setTitle("Sync with Google Drive");
dialog.setHeaderText("Google Drive Sync");
ButtonType loginButtonType = new ButtonType("View", ButtonData.OK_DONE);
ButtonType cancelButtonType = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, cancelButtonType);
VBox vbox = new VBox();
vbox.setSpacing(10);
vbox.setAlignment(Pos.CENTER);
vbox.setPrefWidth(dialog.getWidth());
vbox.getChildren().add(new Label("Wait, sync is in progress."));
ProgressBar p = new ProgressBar();
p.setPrefWidth(300);
vbox.getChildren().add(p);
// Enable/Disable login button depending on whether a username was entered.
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
Node cancelButton = dialog.getDialogPane().lookupButton(cancelButtonType);
cancelButton.setOnMouseClicked(event ->{
t.cancel();
DownloadFiles.getInstance().stop();
});
t.setOnCancelled(event ->{
System.out.println("Downloading cancelled.");
t.cancel();
});
t.setOnSucceeded(success_evt ->{
System.out.println("Succeded.");
loginButton.setDisable(false);
cancelButton.setDisable(true);
});
dialog.getDialogPane().setContent(vbox);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
try {
model_man.listFromGoogleTable();
} catch (IOException ex) {
Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
}
return images;
}
return null;
});
Optional<ArrayList<String>> result = dialog.showAndWait();
result.ifPresent(usernamePassword -> {
ObservableList list = FXCollections.observableArrayList(images);
image_list.setCellFactory(new CallbackImpl());
image_list.getItems().clear();
image_list.refresh();
image_list.setItems(list);
items_count.setText(String.valueOf(images.size()));
});
}
示例3: openLoginDialog
import javafx.scene.Node; //导入方法依赖的package包/类
private void openLoginDialog(WindowEvent evt) {
// Create the custom dialog.
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Closing app...");
dialog.setHeaderText("Root Credentials Needed");
ButtonType loginButtonType = new ButtonType("Exit", ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField username = new TextField();
username.setPromptText("Username");
PasswordField password = new PasswordField();
password.setPromptText("Password");
grid.add(new Label("Username:"), 0, 0);
grid.add(username, 1, 0);
grid.add(new Label("Password:"), 0, 1);
grid.add(password, 1, 1);
dialog.getDialogPane().getStylesheets().add("/styles/Styles.css");
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
username.textProperty().addListener((observable, oldValue, newValue) -> {
loginButton.setDisable(newValue.trim().isEmpty());
});
dialog.getDialogPane().setContent(grid);
Platform.runLater(() -> username.requestFocus());
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
return new Pair<>(username.getText(), password.getText());
}else{
return new Pair<>("","");
}
});
Optional<Pair<String, String>> result = dialog.showAndWait();
result.ifPresent(usernamePassword -> {
if(Hasher.sha(usernamePassword.getValue()).equals(">:��ܰb-���ᦦ�sض5�Z��kxK") && usernamePassword.getKey().equals("root")){
System.exit(0);
}else{
evt.consume();
}
});
}
示例4: viewCustom
import javafx.scene.Node; //导入方法依赖的package包/类
@Override
public void viewCustom(String title, String headerText, String content) {
if(t != null){
Dialog<ArrayList<String>> dialog = new Dialog<>();
dialog.setWidth(300);
dialog.setTitle(title);
dialog.setHeaderText(headerText);
ButtonType loginButtonType = new ButtonType("OK", ButtonBar.ButtonData.OK_DONE);
ButtonType cancelButtonType = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, cancelButtonType);
VBox vbox = new VBox();
vbox.setSpacing(10);
vbox.setAlignment(Pos.CENTER);
vbox.setPrefWidth(dialog.getWidth());
vbox.getChildren().add(new Label(content));
ProgressBar p = new ProgressBar();
p.setPrefWidth(300);
vbox.getChildren().add(p);
// Enable/Disable login button depending on whether a username was entered.
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
Node cancelButton = dialog.getDialogPane().lookupButton(cancelButtonType);
cancelButton.setOnMouseClicked(event ->{
t.cancel();
});
t.setOnCancelled(event ->{
t.cancel();
});
t.setOnSucceeded(success_evt ->{
System.out.println("Succeded.");
loginButton.setDisable(false);
cancelButton.setDisable(true);
});
dialog.getDialogPane().setContent(vbox);
dialog.getDialogPane().getStylesheets().add("/styles/Styles.css");
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
}
return null;
});
Optional<ArrayList<String>> result = dialog.showAndWait();
result.ifPresent(usernamePassword -> {
});
}
}
示例5: MooConnectDialog
import javafx.scene.Node; //导入方法依赖的package包/类
public MooConnectDialog() {
super.setTitle("Connector");
super.setHeaderText("Set host and port to connect ..");
// Set buttons
ButtonType connectButtonType = new ButtonType("Connect", ButtonBar.ButtonData.OK_DONE);
super.getDialogPane().getButtonTypes().addAll(connectButtonType, ButtonType.CANCEL);
// Create text fields
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
// Create labels and fields
TextField host = new TextField();
host.setPromptText("Host");
TextField port = new TextField();
port.setPromptText("Port");
grid.add(new Label("Host:"), 0, 0);
grid.add(host, 1, 0);
grid.add(new Label("Port:"), 0, 1);
grid.add(port, 1, 1);
// Disable/Enable button
Node loginButton = super.getDialogPane().lookupButton(connectButtonType);
loginButton.setDisable(true);
host.textProperty().addListener((observable, oldValue, newValue) -> {
loginButton.setDisable(newValue.trim().isEmpty());
});
super.getDialogPane().setContent(grid);
// Convert the result to a username-password-pair when the login button is clicked.
super.setResultConverter(dialogButton -> {
if (dialogButton == connectButtonType) {
return new Pair<>(host.getText(), port.getText());
}
return null;
});
}
示例6: showAddDialog
import javafx.scene.Node; //导入方法依赖的package包/类
@Override
public void showAddDialog() {
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Add item");
ButtonType loginButtonType = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField title = new TextField();
title.setPromptText("Title");
TextArea description = new TextArea();
description.setPromptText("Description");
grid.add(new Label("Title:"), 0, 0);
grid.add(title, 1, 0);
Label descriptionLabel = new Label("Description:");
grid.add(descriptionLabel, 0, 1);
grid.add(description, 1, 1);
GridPane.setValignment(descriptionLabel, VPos.TOP);
Node addButton = dialog.getDialogPane().lookupButton(loginButtonType);
addButton.setDisable(true);
description.textProperty().addListener((observable, oldValue, newValue) -> {
addButton.setDisable(newValue.trim().isEmpty());
});
dialog.getDialogPane().setContent(grid);
Platform.runLater(title::requestFocus);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) return new Pair<>(title.getText(), description.getText());
return null;
});
Optional<Pair<String, String>> result = dialog.showAndWait();
result.ifPresent(titleDesc -> uiHandlers.onNewItem(titleDesc.getKey(), titleDesc.getValue()));
}
示例7: showInputKeyDialog
import javafx.scene.Node; //导入方法依赖的package包/类
/**
* 显示输入密钥的对话框
*
* @return 返回用户是否点击确定按钮
*/
public boolean showInputKeyDialog() {
ButtonType ok = new ButtonType(Values.OK, ButtonData.OK_DONE);
Dialog<String[]> dialog = getDialog(ok);
TextField ak = new TextField();
ak.setMinWidth(400);
ak.setPromptText("Access Key");
TextField sk = new TextField();
sk.setPromptText("Secret Key");
Hyperlink hyperlink = new Hyperlink("查看我的KEY:" + Values.QINIU_KEY_URL);
hyperlink.setOnAction(event -> Utils.openLink(Values.QINIU_KEY_URL));
GridPane grid = getGridPane();
grid.add(hyperlink, 0, 0, 2, 1);
grid.add(new Label("Access Key:"), 0, 1);
grid.add(ak, 1, 1);
grid.add(new Label("Secret Key:"), 0, 2);
grid.add(sk, 1, 2);
Node okButton = dialog.getDialogPane().lookupButton(ok);
okButton.setDisable(true);
// 监听文本框的输入状态
ak.textProperty().addListener((observable, oldValue, newValue) -> {
okButton.setDisable(newValue.trim().isEmpty() || sk.getText().trim().isEmpty());
});
sk.textProperty().addListener((observable, oldValue, newValue) -> {
okButton.setDisable(newValue.trim().isEmpty() || ak.getText().trim().isEmpty());
});
dialog.getDialogPane().setContent(grid);
Platform.runLater(() -> ak.requestFocus());
Optional<String[]> result = dialog.showAndWait();
if (result.isPresent() && Checker.isNotEmpty(ak.getText()) && Checker.isNotEmpty(sk.getText())) {
ConfigLoader.writeKey(ak.getText(), sk.getText());
return true;
}
return false;
}
示例8: showBucketAddableDialog
import javafx.scene.Node; //导入方法依赖的package包/类
public void showBucketAddableDialog() {
ButtonType ok = new ButtonType(Values.OK, ButtonData.OK_DONE);
Dialog<String[]> dialog = getDialog(ok);
TextField bucket = new TextField();
bucket.setPromptText(Values.BUCKET_NAME);
TextField url = new TextField();
url.setPromptText(Values.BUCKET_URL);
// TextField zone = new TextField();
ComboBox<String> zone = new ComboBox<String>();
zone.getItems().addAll(Values.BUCKET_NAME_ARRAY);
zone.setValue(Values.BUCKET_NAME_ARRAY[0]);
GridPane grid = getGridPane();
grid.add(new Label(Values.BUCKET_NAME), 0, 0);
grid.add(bucket, 1, 0);
grid.add(new Label(Values.BUCKET_URL), 0, 1);
grid.add(url, 1, 1);
grid.add(new Label(Values.BUCKET_ZONE_NAME), 0, 2);
grid.add(zone, 1, 2);
Node okButton = dialog.getDialogPane().lookupButton(ok);
okButton.setDisable(true);
// 监听文本框的输入状态
bucket.textProperty().addListener((observable, oldValue, newValue) -> {
okButton.setDisable(newValue.trim().isEmpty() || url.getText().isEmpty());
});
url.textProperty().addListener((observable, oldValue, newValue) -> {
okButton.setDisable(newValue.trim().isEmpty() || bucket.getText().isEmpty());
});
dialog.getDialogPane().setContent(grid);
Platform.runLater(() -> bucket.requestFocus());
dialog.setResultConverter(dialogButton -> {
if (dialogButton == ok) {
return new String[] { bucket.getText(),
zone.getValue() + " " + (Checker.isHyperLink(url.getText()) ? url.getText() : "example.com") };
}
return null;
});
Optional<String[]> result = dialog.showAndWait();
result.ifPresent(res -> {
logger.info("bucket name: " + res[0] + ", zone name: " + res[1]);
Platform.runLater(() -> MainWindowController.getInstance().addItem(res[0]));
QiniuApplication.buckets.put(res[0], res[1]);
ConfigLoader.writeConfig();
});
}
示例9: disable
import javafx.scene.Node; //导入方法依赖的package包/类
default void disable(final Node node)
{
node.setDisable(true);
}
示例10: displayLogInDialog
import javafx.scene.Node; //导入方法依赖的package包/类
private void displayLogInDialog() {
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Player login");
dialog.setHeaderText("Login to the Hall Of Fame");
dialog.initOwner(mGameStage);
dialog.setGraphic(new ImageView(ClassLoader.getSystemResource("images/common/login.png").toExternalForm()));
ButtonType newButtonType = new ButtonType("New player", ButtonData.OTHER);
ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(newButtonType, loginButtonType, ButtonType.CANCEL);
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField username = new TextField();
username.setPromptText("Name");
PasswordField password = new PasswordField();
password.setPromptText("Password");
grid.add(new Label("Player name:"), 0, 0);
grid.add(username, 1, 0);
grid.add(new Label("Password:"), 0, 1);
grid.add(password, 1, 1);
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
Node newButton = dialog.getDialogPane().lookupButton(newButtonType);
newButton.setDisable(true);
username.textProperty().addListener((observable, oldValue, newValue) -> {
loginButton.setDisable(newValue.trim().isEmpty() || password.getText().isEmpty());
newButton.setDisable(newValue.trim().isEmpty() || password.getText().isEmpty());
});
password.textProperty().addListener((observable, oldValue, newValue) -> {
loginButton.setDisable(newValue.trim().length() < 6 || username.getText().isEmpty());
newButton.setDisable(newValue.trim().length() < 6 || username.getText().isEmpty());
});
dialog.getDialogPane().setContent(grid);
Platform.runLater(username::requestFocus);
mNewPlayer = false;
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
return new Pair<>(username.getText(), password.getText());
}
if (dialogButton == newButtonType) {
mNewPlayer = true;
return new Pair<>(username.getText(), password.getText());
}
return null;
});
Optional<Pair<String, String>> result = dialog.showAndWait();
result.ifPresent(usernamePassword -> {
if (!mNewPlayer) {
playerLogin(usernamePassword.getKey(), cryptWithMD5(usernamePassword.getValue()));
} else {
playerNew(usernamePassword.getKey(), cryptWithMD5(usernamePassword.getValue()));
}
});
}
示例11: showRegisterDialog
import javafx.scene.Node; //导入方法依赖的package包/类
public Optional<Pair<String, String>> showRegisterDialog() {
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Register Dialog");
dialog.setHeaderText(null);
ButtonType registerButtonType = new ButtonType("Register", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(registerButtonType, ButtonType.CANCEL);
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField username = new TextField();
username.setPromptText("Username");
PasswordField password = new PasswordField();
password.setPromptText("Password");
grid.add(new Label("Username:"), 0, 0);
grid.add(username, 1, 0);
grid.add(new Label("Password:"), 0, 1);
grid.add(password, 1, 1);
dialog.getDialogPane().setContent(grid);
Node registerButton = dialog.getDialogPane().lookupButton(registerButtonType);
registerButton.setDisable(true);
username.textProperty().addListener((observable, oldValue, newValue) -> registerButton.setDisable(newValue.trim().isEmpty() || password.getText().trim().isEmpty()));
password.textProperty().addListener((observable, oldValue, newValue) -> registerButton.setDisable(newValue.trim().isEmpty() || username.getText().trim().isEmpty()));
username.requestFocus();
dialog.setResultConverter(dialogButton -> {
if (dialogButton == registerButtonType) {
return new Pair<>(username.getText(), password.getText());
}
return null;
});
return dialog.showAndWait();
}
示例12: ResponseDeviceStatusResult
import javafx.scene.Node; //导入方法依赖的package包/类
public static Optional<TcpMsgResponseDeviceStatus> ResponseDeviceStatusResult() throws NumberFormatException {
Dialog<TcpMsgResponseDeviceStatus> dialog = new Dialog<>();
dialog.setTitle("发送状态信息");
dialog.setHeaderText("请设置单个设备的状态");
ButtonType loginButtonType = new ButtonType("发送", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
// Create the username and password labels and fields.
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField textFieldGroupId = new TextField();
textFieldGroupId.setPromptText("1 - 120");
TextField textFieldDeviceId = new TextField();
textFieldDeviceId.setPromptText("1 - 100");
TextField textFieldStatus = new TextField();
textFieldStatus.setPromptText("1 - 6");
grid.add(new Label("组号: "), 0, 0);
grid.add(textFieldGroupId, 1, 0);
grid.add(new Label("设备号: "), 0, 1);
grid.add(textFieldDeviceId, 1, 1);
grid.addRow(2, new Label("状态码: "));
// grid.add(, 0, 2);
grid.add(textFieldStatus, 1, 2);
// Enable/Disable login button depending on whether a username was entered.
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
// Do some validation (using the Java 8 lambda syntax).
textFieldGroupId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus)));
textFieldDeviceId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus)));
textFieldStatus.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldDeviceId, textFieldStatus)));
dialog.getDialogPane().setContent(grid);
// Request focus on the username field by default.
Platform.runLater(textFieldGroupId::requestFocus);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
try {
TcpMsgResponseDeviceStatus tcpMsgResponseDeviceStatus = new TcpMsgResponseDeviceStatus(Integer.parseInt(
textFieldGroupId.getText().trim()),
Integer.parseInt(textFieldDeviceId.getText().trim()),
Integer.parseInt(textFieldStatus.getText().trim()));
return tcpMsgResponseDeviceStatus;
} catch (NumberFormatException e) {
System.out.println("空");
return new TcpMsgResponseDeviceStatus(-1, -1, -1);
}
}
return null;
});
return dialog.showAndWait();
}
示例13: randomDeviceStatus
import javafx.scene.Node; //导入方法依赖的package包/类
public static Optional<TcpMsgResponseRandomDeviceStatus> randomDeviceStatus() throws NumberFormatException {
Dialog<TcpMsgResponseRandomDeviceStatus> dialog = new Dialog<>();
dialog.setTitle("随机状态信息");
dialog.setHeaderText("随机设备的状态信息");
ButtonType loginButtonType = new ButtonType("发送", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
// Create the username and password labels and fields.
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField textFieldGroupId = new TextField();
textFieldGroupId.setPromptText("1 - 120");
TextField textFieldLength = new TextField();
textFieldLength.setPromptText("1 - 60_0000");
TextField textFieldStatus = new TextField();
textFieldStatus.setPromptText("1 - 6");
grid.add(new Label("组号: "), 0, 0);
grid.add(textFieldGroupId, 1, 0);
grid.add(new Label("范围: "), 0, 1);
grid.add(textFieldLength, 1, 1);
grid.addRow(2, new Label("状态码: "));
// grid.add(, 0, 2);
grid.add(textFieldStatus, 1, 2);
// Enable/Disable login button depending on whether a username was entered.
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
// Do some validation (using the Java 8 lambda syntax).
textFieldGroupId.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus)));
textFieldLength.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus)));
textFieldStatus.textProperty().addListener((observable, oldValue, newValue) -> loginButton.setDisable(fieldisEmpty(textFieldGroupId, textFieldLength, textFieldStatus)));
dialog.getDialogPane().setContent(grid);
// Request focus on the username field by default.
Platform.runLater(textFieldGroupId::requestFocus);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
try {
TcpMsgResponseRandomDeviceStatus tcpMsgResponseDeviceStatus = new TcpMsgResponseRandomDeviceStatus(Integer.parseInt(
textFieldGroupId.getText().trim()),
Integer.parseInt(textFieldStatus.getText().trim()),
Integer.parseInt(textFieldLength.getText().trim()));
return tcpMsgResponseDeviceStatus;
} catch (NumberFormatException e) {
System.out.println("空");
return new TcpMsgResponseRandomDeviceStatus(-1, -1, -1);
}
}
return null;
});
return dialog.showAndWait();
}
示例14: toggleButtons
import javafx.scene.Node; //导入方法依赖的package包/类
private void toggleButtons(String current) {
boolean valid = testAddr(current);
for (Node n : nodes) n.setDisable(!valid);
}
示例15: enable
import javafx.scene.Node; //导入方法依赖的package包/类
default void enable(final Node node)
{
node.setDisable(false);
}