當前位置: 首頁>>代碼示例>>Java>>正文


Java Alert.setGraphic方法代碼示例

本文整理匯總了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();
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:36,代碼來源:Dialogues.java

示例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();
}
 
開發者ID:pxndroid,項目名稱:mountieLibrary,代碼行數:21,代碼來源:MountieQueries.java

示例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();
}
 
開發者ID:bitkylin,項目名稱:ClusterDeviceControlPlatform,代碼行數:10,代碼來源:MainView.java

示例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();
}
 
開發者ID:bitkylin,項目名稱:ClusterDeviceControlPlatform,代碼行數:12,代碼來源:DeviceCellView.java

示例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);
	}
}
 
開發者ID:dhawal9035,項目名稱:WebPLP,代碼行數:39,代碼來源:Main.java

示例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;
}
 
開發者ID:ITB15-S4-GroupD,項目名稱:Planchester,代碼行數:33,代碼來源:AlertHelper.java

示例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();
 }
 
開發者ID:pxndroid,項目名稱:mountieLibrary,代碼行數:21,代碼來源:Books.java

示例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);
}
 
開發者ID:cbrnrd,項目名稱:AlertFX,代碼行數:6,代碼來源:ConfirmExit.java

示例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();    



    }
 
開發者ID:tillind,項目名稱:pandemie,代碼行數:72,代碼來源:BoardController.java


注:本文中的javafx.scene.control.Alert.setGraphic方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。