Java Code Examples for javafx.scene.control.Alert#setContentText()

The following examples show how to use javafx.scene.control.Alert#setContentText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FXMLTimingController.java    From pikatimer with GNU General Public License v3.0 6 votes vote down vote up
public void clearAllOverrides(ActionEvent fxevent){
    //TODO: Prompt and then remove all times associated with that timing location 
    // _or_ all timing locations
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Clear Overrides...");
    alert.setHeaderText("Delete Overrides:");
    alert.setContentText("Do you want to delete all overrides?");

    //ButtonType allButtonType = new ButtonType("All");
    
    ButtonType deleteButtonType = new ButtonType("Delete",ButtonData.YES);
    ButtonType cancelButtonType = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(cancelButtonType, deleteButtonType );

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == deleteButtonType) {
        // delete all
        timingDAO.clearAllOverrides(); 
    }
 
}
 
Example 2
Source File: ScreensSwitcher.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
public boolean exitDialog(Stage stage) {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.initOwner(stage);
alert.setTitle("Confirmation for Exit");//("Confirmation Dialog");
alert.setHeaderText("Leaving mars-sim ?");
//alert.initModality(Modality.APPLICATION_MODAL);
alert.setContentText("Note: Yes to exit mars-sim");
ButtonType buttonTypeYes = new ButtonType("Yes");
ButtonType buttonTypeNo = new ButtonType("No");
  	alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo);
  	Optional<ButtonType> result = alert.showAndWait();
  	if (result.get() == buttonTypeYes){
  		if (mainMenu.getMultiplayerMode() != null)
  			if (mainMenu.getMultiplayerMode().getChoiceDialog() != null)
  				mainMenu.getMultiplayerMode().getChoiceDialog().close();
  		alert.close();
	Platform.exit();
  		System.exit(0);
  		return true;
  	} else {
  		alert.close();
  	    return false;
  	}
 	}
 
Example 3
Source File: MenuController.java    From Online-Food-Ordering-System with MIT License 6 votes vote down vote up
public static boolean infoBox(String infoMessage, String headerText, String title){
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setContentText(infoMessage);
    alert.setTitle(title);
    alert.setHeaderText(headerText);
    alert.getButtonTypes();
    
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        // ... user chose OK button
     return true;
    } else {
    // ... user chose CANCEL or closed the dialog
    return false;
    }
    
}
 
Example 4
Source File: MainDashboardController.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
@FXML
void btnInventory(ActionEvent event) {

        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("School Management System");
        alert.setHeaderText(null);
        alert.setContentText("Sorry..! This feature currently Unavailable for this Version.");
        alert.showAndWait();
}
 
Example 5
Source File: TableManageController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@FXML
@Override
public void deleteAction() {
    List<P> selected = tableView.getSelectionModel().getSelectedItems();
    if (selected == null || selected.isEmpty()) {
        return;
    }
    if (deleteConfirmCheck != null && deleteConfirmCheck.isSelected()) {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle(getBaseTitle());
        alert.setContentText(AppVariables.message("SureDelete"));
        alert.getDialogPane().setMinWidth(Region.USE_PREF_SIZE);
        alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
        ButtonType buttonSure = new ButtonType(AppVariables.message("Sure"));
        ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel"));
        alert.getButtonTypes().setAll(buttonSure, buttonCancel);
        Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
        stage.setAlwaysOnTop(true);
        stage.toFront();
        Optional<ButtonType> result = alert.showAndWait();
        if (result.get() != buttonSure) {
            return;
        }
    }
    if (deleteSelectedData()) {
        refreshAction();
    }
}
 
Example 6
Source File: PCGenFrame.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean showWarningConfirm(String title, String message)
{
	Alert alert = GuiUtility.runOnJavaFXThreadNow(() -> new Alert(Alert.AlertType.CONFIRMATION));
	alert.setTitle(title);
	alert.setContentText(message);
	Optional<ButtonType> buttonType = GuiUtility.runOnJavaFXThreadNow(alert::showAndWait);
	return buttonType.orElse(ButtonType.NO).equals(ButtonType.OK);
}
 
Example 7
Source File: AlertHelper.java    From javase with MIT License 5 votes vote down vote up
public static void showAlert(Alert.AlertType alertType, Window owner, String title, String message) {
    Alert alert = new Alert(alertType);
    alert.setTitle(title);
    alert.setHeaderText(null);
    alert.setContentText(message);
    alert.initOwner(owner);
    alert.show();
}
 
Example 8
Source File: MainDashboardController.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
@FXML
void btnExamMgmt(ActionEvent event) {

        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("School Management System");
        alert.setHeaderText(null);
        alert.setContentText("Sorry..! This feature currently Unavailable for this Version.");
        alert.showAndWait();
}
 
Example 9
Source File: AdminPanelController.java    From Online-Food-Ordering-System with MIT License 5 votes vote down vote up
public static void infoBox(String infoMessage, String headerText, String title){
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setContentText(infoMessage);
    alert.setTitle(title);
    alert.setHeaderText(headerText);
    alert.showAndWait();
}
 
Example 10
Source File: AlertFactory.java    From Motion_Profile_Generator with MIT License 5 votes vote down vote up
public static Alert createExceptionAlert( Exception e, String msg )
{
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle("Exception Dialog");
    alert.setHeaderText("Whoops!");
    alert.setContentText(msg);

    // Create expandable Exception.
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    String exceptionText = sw.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    // Set expandable Exception into the dialog pane.
    alert.getDialogPane().setExpandableContent(expContent);

    return alert;
}
 
Example 11
Source File: RememberingChoiceDialog.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Alert create(final String title,
                           final String header,
                           final String htmlContent,
                           final String checkboxContentKey,
                           final PropertyContext context,
                           final String option
)
{
	GuiAssertions.assertIsNotJavaFXThread();
	Objects.requireNonNull(title);
	Objects.requireNonNull(header);
	Objects.requireNonNull(htmlContent);
	Objects.requireNonNull(context);
	Objects.requireNonNull(option);

	Alert alert = GuiUtility.runOnJavaFXThreadNow(() -> new Alert(Alert.AlertType.INFORMATION));
	alert.setTitle(title);
	alert.setContentText(null);
	alert.setHeaderText(header);
	CheckBox showLicense = new CheckBox(LanguageBundle.getString(checkboxContentKey));
	showLicense.selectedProperty().addListener((observableValue, oldValue, newValue) ->
               context.setBoolean(option, newValue));
	showLicense.setSelected(context.getBoolean(option));
	Platform.runLater(() -> {
		WebView webView = new WebView();
		webView.getEngine().loadContent(htmlContent);
		alert.getDialogPane().setContent(webView);
	});
	alert.getDialogPane().setExpandableContent(showLicense);
	return alert;
}
 
Example 12
Source File: MainDashboardController.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
@FXML
void btnEventMgmt(ActionEvent event) {

        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("School Management System");
        alert.setHeaderText(null);
        alert.setContentText("Sorry..! This feature currently Unavailable for this Version.");
        alert.showAndWait();
}
 
Example 13
Source File: GUIController.java    From dctb-utfpr-2018-1 with Apache License 2.0 5 votes vote down vote up
public void showAboutInformationAlert() {
    Alert aboutInfo = new Alert(Alert.AlertType.INFORMATION);
    
    aboutInfo.setTitle("Sobre o Software");
    aboutInfo.setHeaderText("Sistema de Gerênciamento para Lojas de Informática.");
    aboutInfo.setContentText("Software desenvolvido como trabalho prático para a \ndiscíplina de Programação Desktop.\n");
    
    DialogPane diagPanel = aboutInfo.getDialogPane();
    diagPanel.getStylesheets().add(getClass().getResource("css/alert.css").toExternalForm());
    aboutInfo.showAndWait();
}
 
Example 14
Source File: SchoolInfoController.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
    try {
        School s = SchoolController.schoolInfo();
        if (s != null) {
            SchoolNameField.setText(s.getSchoolName());
            SchoolAddressField.setText(s.getSchoolAddress());
            classAvailableField.setText(s.getClassAvailable());
            schoolTypeField.setText(s.getSchoolType());
            deoDivisionField.setText(s.getDeoDivision());
            municpalCouncilField.setText(s.getMunicpalCouncil());
            policeAreaField.setText(s.getPoliceArea());
            postalCodeField.setText(s.getPostalCode());
            gsDivisionField.setText(s.getDeoDivision());
            eduZoneField.setText(s.getEduZone());
            eduDistrictField.setText(s.getEduDistrict());
            adminDistrictField.setText(s.getAdminDistrict());
            electorateField.setText(s.getElectorate());
            dateOfEstdField.setText(s.getDateOfEstd());
            schoolIDField.setText(s.getSchoolID());
            schoolCensusField.setText(s.getSchoolCensus());
            schoolExamIdField.setText(s.getSchoolExamId());
            totalLandAreaField.setText(s.getTotalLandArea());
            provinceField.setText(s.getProvince());
            nameOfPrincipalField.setText(s.getNameOfPrincipal());
            pricipalNoField.setText(s.getPricipalNo());


        }else{
            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("School Information");
            alert.setHeaderText(null);
            alert.setContentText("No Information Found..!");
            alert.showAndWait();
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(SchoolController.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example 15
Source File: HtmlEditorController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@Override
    public boolean checkBeforeNextAction() {
//        logger.debug(fileChanged.getValue());

        if (fileChanged == null || !fileChanged.getValue()) {
            return true;
        } else {
            Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
            alert.setTitle(getMyStage().getTitle());
            alert.setContentText(AppVariables.message("FileChanged"));
            alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
            ButtonType buttonSave = new ButtonType(AppVariables.message("Save"));
            ButtonType buttonNotSave = new ButtonType(AppVariables.message("NotSave"));
            ButtonType buttonCancel = new ButtonType(AppVariables.message("Cancel"));
            alert.getButtonTypes().setAll(buttonSave, buttonNotSave, buttonCancel);
            Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
            stage.setAlwaysOnTop(true);
            stage.toFront();

            Optional<ButtonType> result = alert.showAndWait();
            if (result.get() == buttonSave) {
                saveAction();
                return true;
            } else {
                return result.get() == buttonNotSave;
            }
        }
    }
 
Example 16
Source File: GameElimniationController.java    From MyBox with Apache License 2.0 4 votes vote down vote up
protected void makeChesses() {
    if (isSettingValues) {
        return;
    }
    catButton.setSelected(false);
    try {
        chessSize = Integer.parseInt(chessSizeSelector.getValue());
        if (chessSize < 20) {
            chessSize = 20;
        }
    } catch (Exception e) {
        chessSize = 50;
    }
    AppVariables.setUserConfigValue("GameEliminationChessImageSize", chessSize + "");
    AppVariables.setUserConfigValue("GameEliminationShadow", shadowCheck.isSelected());
    AppVariables.setUserConfigValue("GameEliminationArc", arcCheck.isSelected());

    selectedChesses.clear();
    String s = "";
    for (int i = 0; i < imagesListview.getItems().size(); ++i) {
        ImageItem item = imagesListview.getItems().get(i);
        item.setIndex(i);
        if (item.isSelected()) {
            selectedChesses.add(i);
            if (s.isBlank()) {
                s += item.getAddress() + "";
            } else {
                s += "," + item.getAddress();
            }
        }
    }
    if (selectedChesses.size() <= minimumAdjacent) {
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setTitle(getBaseTitle());
        alert.setContentText(MessageFormat.format(message("ChessesNumberTooSmall"), minimumAdjacent + ""));
        alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
        Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
        stage.setAlwaysOnTop(true);
        stage.toFront();
        alert.showAndWait();
        return;
    }
    AppVariables.setUserConfigValue("GameEliminationChessImages", s);
    boardSize = selectedChesses.size();
    tabPane.getSelectionModel().select(playTab);
    makeChessBoard();
    makeRulers();
    newGame(true);
}
 
Example 17
Source File: EchoClientControllerWS.java    From examples-javafx-repos1 with Apache License 2.0 4 votes vote down vote up
@FXML
public void disconnect() {
	
	if( !connected.get() ) {
		if( logger.isWarnEnabled() ) {
			logger.warn("client not connected; skipping disconnect");
		}
		return;
	}
	
	if( logger.isDebugEnabled() ) {
		logger.debug("[DISCONNECT]");
	}
	
	Task<Void> task = new Task<Void>() {

		@Override
		protected Void call() throws Exception {
			
			updateMessage("Disconnecting");
			updateProgress(0.1d, 1.0d);
			
			channel.close().sync();					

			updateMessage("Closing group");
			updateProgress(0.5d, 1.0d);
			group.shutdownGracefully().sync();

			return null;
		}

		@Override
		protected void succeeded() {
			
			connected.set(false);
		}

		@Override
		protected void failed() {
			
			connected.set(false);

			Throwable t = getException();
			logger.error( "client disconnect error", t );
			Alert alert = new Alert(AlertType.ERROR);
			alert.setTitle("Client");
			alert.setHeaderText( t.getClass().getName() );
			alert.setContentText( t.getMessage() );
			alert.showAndWait();

		}
		
	};
	
	hboxStatus.visibleProperty().bind( task.runningProperty() );
	lblStatus.textProperty().bind( task.messageProperty() );
	piStatus.progressProperty().bind(task.progressProperty());

	new Thread(task).start();
}
 
Example 18
Source File: DialogMessage.java    From HubTurbo with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void showInformationDialog(String header, String message) {
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setHeaderText(header);
    alert.setContentText(message);
    alert.showAndWait();
}
 
Example 19
Source File: Controller.java    From uip-pc2 with MIT License 4 votes vote down vote up
public void saludar(ActionEvent actionEvent) {
    Alert alerta = new Alert(Alert.AlertType.INFORMATION);
    alerta.setTitle("Saludo");
    alerta.setContentText("Habla malaki!");
    alerta.showAndWait();
}
 
Example 20
Source File: ManageStaffsController.java    From School-Management-System with Apache License 2.0 4 votes vote down vote up
@FXML
void searchStaff(ActionEvent event) {
    try {
        int empNo = Integer.parseInt(EmpNo.getText());
        Staff s = StaffController.searchStaff(empNo);
        if (s != null) {
            empNoField.setText(String.valueOf(s.getEmpNo()));
            teacherNameField.setText(s.getTeacherName());
            nicField.setText(s.getNic());
            dobField.setText(s.getDob());
            doaField.setText(s.getDoa());
            genderField.setText(s.getGender());
            emailField.setText(s.getEmail());
            asmOfDutyField.setText(s.getAssumpOfDuties());
            phoneField.setText(s.getPhone());
            addressField.setText(s.getAddress());
            incDateField.setText(s.getIncDate());
            prsntGradeField.setText(s.getPrsntGrade());


        } else {
            Alert alert = new Alert(Alert.AlertType.ERROR);
            alert.setTitle("Staff Search");
            alert.setHeaderText(null);
            alert.setContentText("Staff Not Found");
            alert.showAndWait();

            empNoField.setText(null);
            teacherNameField.setText(null);
            nicField.setText(null);
            dobField.setText(null);
            doaField.setText(null);
            emailField.setText(null);
            asmOfDutyField.setText(null);
            nicField.setText(null);
            genderField.setText(null);
            phoneField.setText(null);
            addressField.setText(null);
            incDateField.setText(null);
            prsntGradeField.setText(null);
            empName.setText(null);
            empNoOld.setText(null);
            EmpNo.setText(null);
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(StaffController.class.getName()).log(Level.SEVERE, null, ex);
    }
}