javafx.scene.control.Alert#setHeaderText ( )源码实例Demo

下面列出了javafx.scene.control.Alert#setHeaderText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mars-sim   文件: ScreensSwitcher.java
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;
  	}
 	}
 
源代码2 项目: archivo   文件: Archivo.java
private boolean confirmDelete(Recording recording, Tivo tivo) {
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Remove Recording Confirmation");
    alert.setHeaderText("Really remove this recording?");
    alert.setContentText(String.format("Are you sure you want to delete %s from %s?",
            recording.getFullTitle(), tivo.getName()));

    ButtonType deleteButtonType = new ButtonType("Delete", ButtonBar.ButtonData.NO);
    ButtonType keepButtonType = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(deleteButtonType, keepButtonType);
    ((Button) alert.getDialogPane().lookupButton(deleteButtonType)).setDefaultButton(false);
    ((Button) alert.getDialogPane().lookupButton(keepButtonType)).setDefaultButton(true);

    Optional<ButtonType> result = alert.showAndWait();
    if (!result.isPresent()) {
        logger.error("No result from alert dialog");
        return false;
    } else {
        return (result.get() == deleteButtonType);
    }
}
 
源代码3 项目: xltsearch   文件: App.java
@FXML
private void openFolder() {
    if (catalog.get().isIndexing()) {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle("Confirmation");
        alert.setHeaderText("Indexing in progress");
        alert.setContentText("Opening a new folder will cancel indexing. Continue?");
        Optional<ButtonType> result = alert.showAndWait();
        // escape on cancel/close
        if (!result.isPresent() || result.get() != ButtonType.OK) {
            return;
        }
    }
    DirectoryChooser directoryChooser = new DirectoryChooser();
    File dir = directoryChooser.showDialog(stage);
    if (dir != null) {
        if (catalog.get() != null) {
            catalog.get().close();
        }
        catalog.set(new Catalog(dir));
    }  // do nothing on cancel
}
 
源代码4 项目: mars-sim   文件: ScenarioConfigEditorFX.java
public boolean confirmDeleteDialog(String header, String text) {
	Alert dialog = new Alert(Alert.AlertType.CONFIRMATION);
	dialog.initOwner(stage);
	dialog.setHeaderText(header);
	dialog.setContentText(text);
	dialog.getDialogPane().setPrefSize(300, 180);
	// ButtonType buttonTypeYes = new ButtonType("Yes");
	// ButtonType buttonTypeNo = new ButtonType("No");
	// dialog.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo);
	dialog.getButtonTypes().clear();
	dialog.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO);
	// Deactivate Defaultbehavior for yes-Button:
	Button yesButton = (Button) dialog.getDialogPane().lookupButton(ButtonType.YES);
	yesButton.setDefaultButton(false);
	// Activate Defaultbehavior for no-Button:
	Button noButton = (Button) dialog.getDialogPane().lookupButton(ButtonType.NO);
	noButton.setDefaultButton(true);
	final Optional<ButtonType> result = dialog.showAndWait();
	// return result.get() == buttonTypeYes;
	return result.get() == ButtonType.YES;
}
 
源代码5 项目: ns-usbloader   文件: ServiceWindow.java
/** Real window creator */
private static void getNotification(String title, String body, Alert.AlertType type){
    Alert alertBox = new Alert(type);
    alertBox.setTitle(title);
    alertBox.setHeaderText(null);
    alertBox.setContentText(body);
    alertBox.getDialogPane().setMinWidth(Region.USE_PREF_SIZE);
    alertBox.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
    alertBox.setResizable(true);        // Java bug workaround for JDR11/OpenJFX. TODO: nothing. really.
    alertBox.getDialogPane().getStylesheets().add(AppPreferences.getInstance().getTheme());

    Stage dialogStage = (Stage) alertBox.getDialogPane().getScene().getWindow();
    dialogStage.setAlwaysOnTop(true);
    dialogStage.getIcons().addAll(
            new Image("/res/warn_ico32x32.png"),
            new Image("/res/warn_ico48x48.png"),
            new Image("/res/warn_ico64x64.png"),
            new Image("/res/warn_ico128x128.png")
    );
    alertBox.show();
    dialogStage.toFront();
}
 
源代码6 项目: pikatimer   文件: FXMLTimingController.java
public void resetTimingLocations(ActionEvent fxevent){
    // prompt 
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Confirm Resetting all Timing Locations");
    alert.setHeaderText("This action cannot be undone.");
    alert.setContentText("This will reset the timing locations to default values.\nAll splits will be reassigned to one of the default locations.");
    //Label alertContent = new Label("This will reset the timing locations to default values.\nAll splits will be reassigned to one of the default locations.");
    //alertContent.setWrapText(true); 
    //alert.getDialogPane().setContent(alertContent);
    
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        timingDAO.createDefaultTimingLocations();
    } else {
        // ... user chose CANCEL or closed the dialog
    }
    
    timingLocAddButton.requestFocus();
    //timingLocAddButton.setDefaultButton(true);
}
 
源代码7 项目: PeerWasp   文件: RecoverFileController.java
private void onFileRecoveryFailed(final String message) {
	Runnable failed = new Runnable() {
		@Override
		public void run() {
			setBusy(false);
			setStatus("");

			if(!versionSelector.isCancelled()) {
				// show error if user did not initiate cancel action
				Alert dlg = DialogUtils.createAlert(AlertType.ERROR);
				dlg.setTitle("File Recovery Failed");
				dlg.setHeaderText("File recovery did not succeed.");
				dlg.setContentText(message);
				dlg.showAndWait();
			}
			getStage().close();
		}
	};

	if (Platform.isFxApplicationThread()) {
		failed.run();
	} else {
		Platform.runLater(failed);
	}
}
 
源代码8 项目: pikatimer   文件: FXMLEventController.java
public void resetRaces(ActionEvent fxevent){
    // prompt 
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Confirm Resetting All Races");
    alert.setContentText("This action cannot be undone.");
    alert.setHeaderText("This will delete all configured races!");
    //Label alertContent = new Label("This will reset the timing locations to default values.\nAll splits will be reassigned to one of the default locations.");
    //alertContent.setWrapText(true); 
    //alert.getDialogPane().setContent(alertContent);
    
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        raceDAO.clearAll();
    } else {
        // ... user chose CANCEL or closed the dialog
    }
    
    raceAddButton.requestFocus();
    raceAddButton.setDefaultButton(true);
}
 
源代码9 项目: PeerWasp   文件: ShareFolderUILoader.java
private static void showError(final String message) {
	Runnable dialog = new Runnable() {
		@Override
		public void run() {
			Alert dlg = DialogUtils.createAlert(AlertType.ERROR);
			dlg.setTitle("Error Share Folder.");
			dlg.setHeaderText("Could not share folder.");
			dlg.setContentText(message);
			dlg.showAndWait();
		}
	};

	if (Platform.isFxApplicationThread()) {
		dialog.run();
	} else {
		Platform.runLater(dialog);
	}
}
 
源代码10 项目: dctb-utfpr-2018-1   文件: GUIController.java
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();
}
 
源代码11 项目: metastone   文件: DialogMediator.java
private void displayErrorMessage(String header, String message) {
	Alert alert = new Alert(AlertType.ERROR);
	alert.setTitle("Error");
	alert.setHeaderText(header);
	alert.setContentText(message);
	alert.showAndWait();
}
 
源代码12 项目: mars-sim   文件: MultiplayerTray.java
public void createAlert(String text) {
   	//Stage stage = new Stage();
       stage.getIcons().add(new Image(this.getClass().getResource("/icons/lander_hab.svg").toString()));
       String header = null;
       //String text = null;
       header = "Multiplayer Host Server";
       //System.out.println("confirm dialog pop up.");
	Alert alert = new Alert(AlertType.CONFIRMATION);
	alert.initOwner(stage);
	alert.setTitle("Mars Simulation Project");
	alert.setHeaderText(header);
	alert.setContentText(text);
	alert.initModality(Modality.APPLICATION_MODAL);

	Optional<ButtonType> result = alert.showAndWait();
	if (result.get() == ButtonType.YES){
		if (multiplayerServer != null) {
        	// TODO: fix the loading problem for server mode
        	multiplayerServer.setServerStopped(true);
        }
		notificationTimer.cancel();
		Platform.exit();
		tray.remove(trayIcon);
	    System.exit(0);
	}
	//else {
	//}
}
 
源代码13 项目: Weather-Forecast   文件: JFxBuilder.java
private void createAlertDialog(DialogObject dialog) {
    Alert alert = new Alert(dialog.getType());
    alert.setTitle(dialog.getTitle());
    alert.setHeaderText(dialog.getHeader());
    alert.setContentText(dialog.getContent());

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK) {
        System.exit(0);
    } else {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        dialog.getexception().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);

        alert.getDialogPane().setExpandableContent(expContent);

        alert.showAndWait();
    }
}
 
源代码14 项目: Library-Assistant   文件: AlertMaker.java
public static void showSimpleAlert(String title, String content) {
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle(title);
    alert.setHeaderText(null);
    alert.setContentText(content);
    styleAlert(alert);
    alert.showAndWait();
}
 
@FXML
void btnLibraryMgmt(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();
}
 
public boolean validateNIC(TextField txt) {
    if (txt.getText().matches("^(\\d{9}|\\d{12})[VvXx]$")|| (txt.getText().isEmpty())) {

        return true;
    } else {
        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Student Registration");
        alert.setHeaderText(null);
        alert.setContentText("Invalid NIC Number..!");
        alert.showAndWait();

        return false;
    }
}
 
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();
}
 
源代码18 项目: constellation   文件: TemplateListDialog.java
String getName(final Object owner, final File delimIoDir) {
    final String[] templateLabels = getFileLabels(delimIoDir);

    final Alert dialog = new Alert(Alert.AlertType.CONFIRMATION);

    final TextField label = new TextField();
    label.setPromptText("Template label");

    final ObservableList<String> q = FXCollections.observableArrayList(templateLabels);
    final ListView<String> nameList = new ListView<>(q);
    nameList.setEditable(false);
    nameList.setOnMouseClicked(event -> {
        label.setText(nameList.getSelectionModel().getSelectedItem());
        if (event.getClickCount() > 1) {
            dialog.setResult(ButtonType.OK);
        }
    });

    final HBox prompt = new HBox(new Label("Name: "), label);
    prompt.setPadding(new Insets(10, 0, 0, 0));

    final VBox vbox = new VBox(nameList, prompt);

    dialog.setResizable(false);
    dialog.setTitle("Import template names");
    dialog.setHeaderText(String.format("Select an import template to %s.", isLoading ? "load" : "save"));
    dialog.getDialogPane().setContent(vbox);
    final Optional<ButtonType> option = dialog.showAndWait();
    if (option.isPresent() && option.get() == ButtonType.OK) {
        final String name = label.getText();
        final File f = new File(delimIoDir, FilenameEncoder.encode(name + ".json"));
        boolean go = true;
        if (!isLoading && f.exists()) {
            final String msg = String.format("'%s' already exists. Do you want to overwrite it?", name);
            final Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
            alert.setHeaderText("Import template exists");
            alert.setContentText(msg);
            final Optional<ButtonType> confirm = alert.showAndWait();
            go = confirm.isPresent() && confirm.get() == ButtonType.OK;
        }

        if (go) {
            return name;
        }
    }

    return null;
}
 
@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();
}
 
源代码20 项目: pikatimer   文件: FXMLEventController.java
public void removeRace(ActionEvent fxevent){
    
    final Race r = raceTableView.getSelectionModel().getSelectedItem();
    
    if (r == null) return;
    
    // Do we have any runner's assigned?
    BooleanProperty assignedRunners = new SimpleBooleanProperty(false);
    BooleanProperty assignedTimingLoc= new SimpleBooleanProperty(false);
    StringProperty assignedTimingLocations = new SimpleStringProperty();

    ParticipantDAO.getInstance().listParticipants().forEach(x ->{
        x.getWaveIDs().forEach(w -> {
            if (RaceDAO.getInstance().getWaveByID(w).getRace().equals(r)) {
                assignedRunners.setValue(Boolean.TRUE);
                //System.out.println("Race " + RaceDAO.getInstance().getWaveByID(w).getRace().getRaceName() + " is in use by " + x.fullNameProperty().getValueSafe());
            }
        });
    });
    
    TimingDAO.getInstance().listTimingLocations().forEach(x -> {
        if (x.getAutoAssignRaceID() >= 0 ) {
            assignedTimingLoc.setValue(Boolean.TRUE);
            if (assignedTimingLocations.isEmpty().get()) assignedTimingLocations.setValue(x.getLocationName());
            else assignedTimingLocations.setValue(assignedTimingLocations.getValue() + "\n" + x.getLocationName());
        }
    });
    
    if (assignedRunners.get() || assignedTimingLoc.get()) {
        Alert alert = new Alert(AlertType.INFORMATION);
        alert.setTitle("Unable to Remove Race");
        alert.setHeaderText("Unable to remove the selected race.");
        if (assignedRunners.get()) alert.setContentText("This race currently has assigned runners.\nPlease assign them to a different race before removing.");
        if (assignedTimingLoc.get()) alert.setContentText("The following timing locations are set to\nauto-assign runners to this race:\n\n"+assignedTimingLocations.getValueSafe());

        alert.showAndWait();
    } else {
        raceDAO.removeRace(raceTableView.getSelectionModel().getSelectedItem());
        raceTableView.getSelectionModel().select(raceList.indexOf(0));
        raceAddButton.requestFocus();
        raceAddButton.setDefaultButton(false);

        if (raceList.size() > 1) { 
            multipleRacesCheckBox.setDisable(true);
            raceRemoveButton.setDisable(false); 
        } else {
            multipleRacesCheckBox.setDisable(false);
            raceRemoveButton.setDisable(true);
        }
    }
   
}