本文整理汇总了Java中javafx.scene.control.Dialog.setGraphic方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.setGraphic方法的具体用法?Java Dialog.setGraphic怎么用?Java Dialog.setGraphic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Dialog
的用法示例。
在下文中一共展示了Dialog.setGraphic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public void show() {
paneController.load();
ResourceBundle i18n = toolBox.getI18nBundle();
Dialog<ButtonType> dialog = new Dialog<>();
dialog.setTitle(i18n.getString("prefsdialog.title"));
dialog.setHeaderText(i18n.getString("prefsdialog.header"));
GlyphsFactory gf = MaterialIconFactory.get();
Text settingsIcon = gf.createIcon(MaterialIcon.SETTINGS, "30px");
dialog.setGraphic(settingsIcon);
dialog.getDialogPane()
.getButtonTypes()
.addAll(ButtonType.OK, ButtonType.CANCEL);
dialog.getDialogPane()
.setContent(paneController.getRoot());
dialog.getDialogPane()
.getStylesheets()
.addAll(toolBox.getStylesheets());
Optional<ButtonType> buttonType = dialog.showAndWait();
buttonType.ifPresent(bt -> {
if (bt == ButtonType.OK) {
paneController.save();
}
});
}
示例2: init
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
protected void init() {
String tooltip = toolBox.getI18nBundle().getString("buttons.upon");
MaterialIconFactory iconFactory = MaterialIconFactory.get();
Text icon = iconFactory.createIcon(MaterialIcon.VERTICAL_ALIGN_BOTTOM, "30px");
Text icon2 = iconFactory.createIcon(MaterialIcon.VERTICAL_ALIGN_BOTTOM, "30px");
initializeButton(tooltip, icon);
ResourceBundle i18n = toolBox.getI18nBundle();
Dialog<String> dialog = dialogController.getDialog();
dialog.setTitle(i18n.getString("buttons.upon.dialog.title"));
dialog.setHeaderText(i18n.getString("buttons.upon.dialog.header"));
dialog.setContentText(i18n.getString("buttons.upon.dialog.content"));
dialog.setGraphic(icon2);
dialog.getDialogPane().getStylesheets().addAll(toolBox.getStylesheets());
}
示例3: showOptions
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
@Override
public void showOptions() {
Dialog<String> dialog = new Dialog<>();
dialog.setTitle("Perception-Action Configuration");
dialog.setHeaderText("You can define next action in function of agent perception (up, left, right and down)");
dialog.getDialogPane().setPrefSize(500, 600);
FontIcon icon = new FontIcon(FontAwesome.COGS);
icon.setIconSize(64);
dialog.setGraphic(icon);
ButtonType applyChanges = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(applyChanges, ButtonType.CANCEL);
try {
FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("PerceptionActionAgent.fxml"));
Parent root = fxmlLoader.load();
dialog.getDialogPane().setContent(root);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == applyChanges) {
PerceptionActionAgentController configurationController = fxmlLoader.getController();
for (PerceptionActionAgentController.PerceptionRule rule : configurationController.tableContent) {
((PerceptionAction) getAlgorithm()).addRule(rule.getLeft(), rule.getRight(), rule.getUp(), rule.getDown(), Directions.valueOf(rule.getAction()));
}
return null;
}
return null;
});
} catch (IOException e) {
new ErrorView("No possible load agent configuration");
e.printStackTrace();
}
Optional<String> s = dialog.showAndWait();
}
示例4: deploy
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
@FXML
protected void deploy() {
eventBus.post(new WarningEvent(
"Deploy has been deprecated",
"The deploy tool has been deprecated and is no longer supported. "
+ "It will be removed in a future release.\n\n"
+ "Instead, use code generation to create a Java, C++, or Python class that handles all"
+ " the OpenCV code and can be easily integrated into a WPILib robot program."));
ImageView graphic = new ImageView(new Image("/edu/wpi/grip/ui/icons/settings.png"));
graphic.setFitWidth(DPIUtility.SMALL_ICON_SIZE);
graphic.setFitHeight(DPIUtility.SMALL_ICON_SIZE);
deployPane.requestFocus();
Dialog<ButtonType> dialog = new Dialog<>();
dialog.setTitle("Deploy");
dialog.setHeaderText("Deploy");
dialog.setGraphic(graphic);
dialog.getDialogPane().getButtonTypes().setAll(ButtonType.CLOSE);
dialog.getDialogPane().styleProperty().bind(root.styleProperty());
dialog.getDialogPane().getStylesheets().setAll(root.getStylesheets());
dialog.getDialogPane().setContent(deployPane);
dialog.setResizable(true);
dialog.showAndWait();
}
示例5: showSpeciesManager
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static void showSpeciesManager() {
Dialog<String> dialog = new Dialog<>();
dialog.setTitle("Species Manager");
dialog.setHeaderText("You can manage environment species with the following options: \n - create specie, \n - delete specie");
dialog.getDialogPane().setPrefSize(500, 600);
FontIcon icon = new FontIcon(FontAwesome.COGS);
icon.setIconSize(64);
dialog.setGraphic(icon);
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CLOSE);
try {
FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("SpeciesConfiguration.fxml"));
Parent root = fxmlLoader.load();
dialog.getDialogPane().setContent(root);
dialog.setResultConverter(dialogButton -> {
return null;
});
} catch (IOException e) {
new ErrorView("No possible load agent configuration");
e.printStackTrace();
}
Optional<String> result = dialog.showAndWait();
}
示例6: showOptions
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
*
*/
@Override
public void showOptions() {
Dialog<String> dialog = new Dialog<>();
dialog.setTitle("Agent Configuration");
dialog.setHeaderText("You can edit: \n - appearance, \n - internal algorithm, \n - objectives, \n - and export and import agents");
dialog.getDialogPane().setPrefSize(500, 600);
FontIcon icon = new FontIcon(FontAwesome.COGS);
icon.setIconSize(64);
dialog.setGraphic(icon);
ButtonType applyChanges = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(applyChanges, ButtonType.CANCEL);
try {
FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("CollectionAgentConfiguration.fxml"));
Parent root = fxmlLoader.load();
dialog.getDialogPane().setContent(root);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == applyChanges) {
CollectorConfigurationController configurationController = fxmlLoader.getController();
setAlgorithm(configurationController.getAlgorithm());
return null;
}
return null;
});
} catch (IOException e) {
new ErrorView("No possible load agent configuration");
e.printStackTrace();
}
Optional<String> result = dialog.showAndWait();
}
示例7: showOptions
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
*
*/
@Override
public void showOptions() {
Dialog<String> dialog = new Dialog<>();
dialog.setTitle("Agent Configuration");
dialog.setHeaderText("You can edit: \n - appearance, \n - internal algorithm, \n - objectives, \n - and export and import agents");
dialog.getDialogPane().setPrefSize(500, 600);
FontIcon icon = new FontIcon(FontAwesome.COGS);
icon.setIconSize(64);
dialog.setGraphic(icon);
ButtonType applyChanges = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(applyChanges, ButtonType.CANCEL);
try {
FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("MachineLearningAgentConfiguration.fxml"));
Parent root = fxmlLoader.load();
dialog.getDialogPane().setContent(root);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == applyChanges) {
MachineLearningAgentConfigurationController machineLearningConfigurationController = fxmlLoader.getController();
setAlgorithm(machineLearningConfigurationController.getAlgorithm());
return null;
}
return null;
});
} catch (IOException e) {
new ErrorView("No possible load agent configuration");
e.printStackTrace();
}
Optional<String> result = dialog.showAndWait();
}
示例8: showOptions
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
@Override
public void showOptions() {
Dialog<String> dialog = new Dialog<>();
dialog.setTitle("Swarm Nest Configuration");
dialog.setHeaderText("You can select the type of swarm algorithm and some properties");
dialog.getDialogPane().setPrefSize(500, 600);
FontIcon icon = new FontIcon(FontAwesome.COGS);
icon.setIconSize(64);
dialog.setGraphic(icon);
ButtonType applyChanges = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(applyChanges, ButtonType.CANCEL);
try {
FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("SwarmNestConfiguration.fxml"));
Parent root = fxmlLoader.load();
dialog.getDialogPane().setContent(root);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == applyChanges) {
SwarmNestConfigurationController configurationController = fxmlLoader.getController();
setAlgorithm(configurationController.getAlgorithm().clone());
return null;
}
return null;
});
} catch (IOException e) {
new ErrorView("No possible load agent configuration");
e.printStackTrace();
}
Optional<String> s = dialog.showAndWait();
}
示例9: showOptions
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
@Override
public void showOptions() {
Dialog<String> dialog = new Dialog<>();
dialog.setTitle("Neural Network Agent Configuration");
dialog.setHeaderText("You can select the type of neural network and some properties");
dialog.getDialogPane().setPrefSize(500, 600);
FontIcon icon = new FontIcon(FontAwesome.COGS);
icon.setIconSize(64);
dialog.setGraphic(icon);
ButtonType applyChanges = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(applyChanges, ButtonType.CANCEL);
try {
FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("NeuralNetworkAgentConfiguration.fxml"));
Parent root = fxmlLoader.load();
dialog.getDialogPane().setContent(root);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == applyChanges) {
NeuralNetworkAgentConfigurationController configurationController = fxmlLoader.getController();
setAlgorithm(configurationController.getAlgorithm());
return null;
}
return null;
});
} catch (IOException e) {
new ErrorView("No possible load agent configuration");
e.printStackTrace();
}
Optional<String> s = dialog.showAndWait();
}
示例10: showOptions
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
@Override
public void showOptions() {
Dialog<String> dialog = new Dialog<>();
dialog.setTitle("Perception-Action Configuration");
dialog.setHeaderText("You can define next action in function of agent perception (up, left, right and down)");
dialog.getDialogPane().setPrefSize(500, 600);
FontIcon icon = new FontIcon(FontAwesome.COGS);
icon.setIconSize(64);
dialog.setGraphic(icon);
ButtonType applyChanges = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(applyChanges, ButtonType.CANCEL);
try {
FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("SituationActionConfiguration.fxml"));
Parent root = fxmlLoader.load();
dialog.getDialogPane().setContent(root);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == applyChanges) {
SituationActionController configurationController = fxmlLoader.getController();
for (SituationActionController.SituationRule rule : configurationController.tableContent) {
((SituationAction) getAlgorithm()).addRule(rule.getIEval(), rule.getDirection());
}
return null;
}
return null;
});
} catch (IOException e) {
new ErrorView("No possible load agent configuration");
e.printStackTrace();
}
Optional<String> s = dialog.showAndWait();
}
示例11: acceptCallDialog
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public void acceptCallDialog(final Client client) {
// set current client
Core.instance().main().showUser(client);
Core.instance().main().selectVideoCall();
// create the custom dialog.
Dialog<Boolean> dialog = new Dialog<>();
dialog.setTitle("Incoming Call!");
dialog.setHeaderText(userName.getText());
dialog.setContentText(userName.getText() + " is calling...\n"
+ "Do you want to accept this call?");
// set the icon
dialog.setGraphic(new ImageView(userPhoto.getImage()));
// set the button types.
ButtonType acceptButton = new ButtonType("Accept", ButtonData.OK_DONE);
ButtonType declineButton = new ButtonType("Decline", ButtonData.CANCEL_CLOSE);
dialog.getDialogPane().getButtonTypes().addAll(acceptButton, declineButton);
// define result converter
dialog.setResultConverter(dialogButton -> {
return dialogButton == acceptButton;
});
// return the result
Optional<Boolean> result = dialog.showAndWait();
if (result.isPresent() && result.get()) {
Core.instance().dialer().acceptResponse(client, null);
} else {
Core.instance().dialer().acceptResponse(client, new Exception("Call was rejected"));
}
}
示例12: displayDevKeyDialog
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
* This is for testing purposes, to allow the developer select any level to play
*/
private void displayDevKeyDialog() {
Dialog<String> dialog = new Dialog<>();
dialog.setTitle("Developer mode");
dialog.setHeaderText("Enter developer key");
dialog.initOwner(mGameStage);
dialog.setGraphic(new ImageView(ClassLoader.getSystemResource("images/common/lockpad.png").toExternalForm()));
ButtonType loginButtonType = new ButtonType("Enter", 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, 20));
PasswordField password = new PasswordField();
password.setPromptText("Key");
grid.add(new Label("Key:"), 0, 1);
grid.add(password, 1, 1);
Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
loginButton.setDisable(true);
password.textProperty().addListener((observable, oldValue, newValue) -> {
loginButton.setDisable(newValue.trim().isEmpty());
});
dialog.getDialogPane().setContent(grid);
Platform.runLater(password::requestFocus);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
return password.getText();
}
return null;
});
Optional<String> result = dialog.showAndWait();
result.ifPresent(usernamePassword -> {
/*
* Encode your own key and place below
*/
String encodedPass = cryptWithMD5(result.get());
if(encodedPass != null && encodedPass.equals("efd71744ab79091beef4a125935a73")){
mDevMode = true;
playerLogOut();
} else {
mDevMode = false;
Toast.makeText(mGameStage, "Authentication error", TOAST_LENGTH_SHORT);
}
});
}
示例13: displayLogInDialog
import javafx.scene.control.Dialog; //导入方法依赖的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()));
}
});
}
示例14: displayManagePlayerDialog
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
private void displayManagePlayerDialog() {
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Manage players");
dialog.setHeaderText("Select player account");
dialog.initOwner(mGameStage);
dialog.setGraphic(new ImageView(ClassLoader.getSystemResource("images/common/login.png").toExternalForm()));
ButtonType newButtonType = new ButtonType("New player", ButtonData.OK_DONE);
ButtonType loginButtonType = new ButtonType("Delete player", ButtonData.OTHER);
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) {
playerDelete(usernamePassword.getKey(), cryptWithMD5(usernamePassword.getValue()));
} else {
playerNew(usernamePassword.getKey(), cryptWithMD5(usernamePassword.getValue()));
}
});
}
示例15: showLoginDialog
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
* login Dialog 로그인 처리 다이얼로그
*
* @param consumer
* @return
*/
public static <T> Optional<Pair<String, String>> showLoginDialog(Consumer<? super Pair<String, String>> consumer) {
// Create the custom dialog.
Dialog<Pair<String, String>> dialog = new Dialog<>();
dialog.setTitle("Login Dialog");
dialog.setHeaderText("Look, a Custom Login Dialog");
dialog.setGraphic(new ImageView(new Image("file:resources/images/login.png")));
// Set the button types.
ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
ButtonType localButtonType = new ButtonType("Local", ButtonData.APPLY);
dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, localButtonType, 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 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);
// 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).
username.textProperty().addListener((observable, oldValue, newValue) -> {
loginButton.setDisable(newValue.trim().isEmpty());
});
dialog.getDialogPane().setContent(grid);
// Request focus on the username field by default.
Platform.runLater(() -> username.requestFocus());
// Convert the result to a username-password-pair when the login button
// is clicked.
dialog.setResultConverter(dialogButton -> {
if (dialogButton == loginButtonType) {
return new Pair<>(username.getText(), password.getText());
} else if (dialogButton == localButtonType) {
return new Pair<>(MEMO_LOCAL_USER, "");
}
return null;
});
Optional<Pair<String, String>> result = dialog.showAndWait();
result.ifPresent(consumer);
return result;
}