本文整理匯總了Java中javafx.scene.control.Alert.setGraphic方法的典型用法代碼示例。如果您正苦於以下問題:Java Alert.setGraphic方法的具體用法?Java Alert.setGraphic怎麽用?Java Alert.setGraphic使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.Alert
的用法示例。
在下文中一共展示了Alert.setGraphic方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showAlertDialogue
import javafx.scene.control.Alert; //導入方法依賴的package包/類
/**
* Spawns an error dialogue detailing the given exception.
* <p>
* The given message will be used as the dialogue's header, and the exception's stack
* trace will appear in the hidden "more information" dropdown.
* <p>
* If the exception has a message, it will be displayed in the dialogue's content
* field, prefaced by "Cause:"
*
* @param exception
* The exception to display
* @param message
* A message to describe the context of the dialogue, usually why the
* dialogue is appearing (e.g. "An error has occurred!")
*/
public static void showAlertDialogue(Exception exception, String message)
{
String context = exception.getMessage();
boolean valid = (context != null && !context.isEmpty());
context = (valid) ? "Cause: " + context : null;
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Exception Dialog");
alert.setHeaderText(message);
alert.setContentText(context);
alert.setGraphic(null);
String exceptionText = getStackTraceAsString(exception);
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(false);
alert.getDialogPane().setExpandableContent(textArea);
alert.showAndWait();
}
示例2: displayAlert
import javafx.scene.control.Alert; //導入方法依賴的package包/類
/**
* Displays and alert window if the connection to the data base failed.
* @param type Type of alert to be displayed.
* @param title title of the alerts window.
* @param messageHeader Message to be displayed on the alert window.
* @param extraText extra text to display (optional)
*/
private void displayAlert(Alert.AlertType type, String title, String messageHeader,
String extraText)
{
Alert alert = new Alert(type);
//If database is not available
alert.setTitle(title);
alert.setHeaderText(messageHeader);
Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
stage.getIcons().add(new Image("images/db.png"));
alert.setGraphic(new ImageView(("images/db.png")));
alert.showAndWait();
}
示例3: onActionMenuItemAbout
import javafx.scene.control.Alert; //導入方法依賴的package包/類
@FXML
private void onActionMenuItemAbout(ActionEvent event) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("關於");
alert.setHeaderText("集群設備模擬客戶端 " + KySetting.VERSION);
alert.setGraphic(null);
alert.setContentText(ViewUtil.getOsInfo());
alert.showAndWait();
}
示例4: nobindalertdialog
import javafx.scene.control.Alert; //導入方法依賴的package包/類
/**
* 未綁定設備彈出警告
*/
private void nobindalertdialog() {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("警告");
alert.setHeaderText(null);
alert.setGraphic(null);
alert.setContentText("未關聯相應的設備");
alert.showAndWait();
}
示例5: addProject
import javafx.scene.control.Alert; //導入方法依賴的package包/類
private void addProject(Project project)
{
Project existingProject = getProjectByName(project.getName());
if (existingProject != null)
{
if (existingProject.getPath().equals(project.getPath()))
{
// Projects are the same
showInfoDialogue("This project is already open!");
projectExplorer.expandProject(existingProject);
}
else
{
// Project with the same name already exists
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Confirmation Dialog");
alert.setGraphic(null);
alert.setHeaderText(null);
alert.setContentText("A project with the name \""
+ project.getName()
+ "\" already exists. In order to open this project, you must choose a different name."
+ "\n\n"
+ "Press OK to choose a new name, or Cancel to close this dialog.");
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK)
{
boolean renamed = renameProject(project);
if (renamed)
addProject(project);
}
}
}
else
{
projects.add(project);
}
}
示例6: showMessage
import javafx.scene.control.Alert; //導入方法依賴的package包/類
private static Optional showMessage(String title, String headerText, String contentText, Alert.AlertType type, ImageView icon, List<ButtonType> buttonTypeList, Pane pane) {
GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
pane.setDisable(true);
Alert alert = new Alert(type);
alert.setTitle(title);
alert.getDialogPane().setMaxHeight(graphicsDevice.getDisplayMode().getHeight() * 0.9);
alert.getDialogPane().setMaxWidth(graphicsDevice.getDisplayMode().getWidth() * 0.9);
if(icon != null) {
alert.setGraphic(icon);
}
alert.setHeaderText(headerText);
Label contentTextElement = new Label(contentText);
contentTextElement.setWrapText(true);
ScrollPane contentTextElementScrollPane = new ScrollPane(contentTextElement);
alert.getDialogPane().setContent(contentTextElementScrollPane);
if(buttonTypeList != null) {
alert.getButtonTypes().setAll(buttonTypeList);
}
Optional optional = alert.showAndWait();
alert.close();
pane.setDisable(false);
return optional;
}
示例7: displayAlert
import javafx.scene.control.Alert; //導入方法依賴的package包/類
/**
* Displays and alert window if the there was an error updating books
* avaliable copies.
* @param type type of alert to display
* @param title the title of the alert window
* @param messageHeader the message on the alert window
* @param errorCode the error code to be displayed if multiple avaliable.
*/
private void displayAlert(Alert.AlertType type, String title,
String messageHeader, String errorCode)
{
Alert alert = new Alert(type);
alert.setTitle(title);
alert.setContentText(messageHeader);
alert.setHeaderText(null);
Stage stage5 = (Stage) alert.getDialogPane().getScene().getWindow();
stage5.getIcons().add(new Image("images/emptySpace.png"));
alert.setGraphic(new ImageView(("images/emptySpace.png")));
alert.showAndWait();
}
示例8: setGraphicToError
import javafx.scene.control.Alert; //導入方法依賴的package包/類
private void setGraphicToError(Alert alert){
Label label = new Label();
label.getStyleClass().addAll("alert", "error", "dialog-pane");
alert.setGraphic(label);
}
示例9: afficherCarte
import javafx.scene.control.Alert; //導入方法依賴的package包/類
public void afficherCarte(String link){
Label cardLbl = new Label("Carte jouer"+this.param.getName());
Image img = new Image(link);
ImageView imgView = new ImageView(img);
imgView.setRotate(90);
imgView.setFitHeight(500);
imgView.setFitWidth(620);
FXMLLoader loader = new FXMLLoader(
getClass().getResource(
"/com/miage/pandemie/view/paneCard.fxml"
)
);
DialogPane pane = null;
try {
pane = loader.load();
} catch (IOException ex) {
Logger.getLogger(BoardController.class.getName()).log(Level.SEVERE, null, ex);
}
GridPane gridImageView = (GridPane) pane.getContent();
GridPane gridLbl = (GridPane) pane.getHeader();
gridImageView.add(imgView, 0, 0);
gridLbl.add(cardLbl, 0, 0);
this.defausseInfectionImageView.setImage(img);
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setWidth(590);
alert.setHeight(765);
alert.setTitle("Carte jouer");
alert.setContentText("");
alert.setGraphic(pane);
alert.showAndWait();
}