本文整理匯總了Java中javafx.scene.control.Alert類的典型用法代碼示例。如果您正苦於以下問題:Java Alert類的具體用法?Java Alert怎麽用?Java Alert使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Alert類屬於javafx.scene.control包,在下文中一共展示了Alert類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onActionAbout
import javafx.scene.control.Alert; //導入依賴的package包/類
/**
* Display an alert for the about button
*/
@FXML
private void onActionAbout() {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("About...");
alert.setHeaderText(null);
alert.setContentText("Author: Guduche\nVersion: 1.0.1");
alert.getButtonTypes().clear();
ButtonType boutonOk = new ButtonType("Ok");
alert.getButtonTypes().add(boutonOk);
ButtonType boutonGithub = new ButtonType("Github project");
alert.getButtonTypes().add(boutonGithub);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == boutonGithub) {
try {
java.awt.Desktop.getDesktop().browse(new URI("https://github.com/Guduche/UTGenerator"));
} catch (Exception e) {
}
}
}
示例2: alwaysInTop
import javafx.scene.control.Alert; //導入依賴的package包/類
public static void alwaysInTop(Alert alert) {
try{
DialogPane root = alert.getDialogPane();
Stage dialogStage = new Stage(StageStyle.UTILITY);
for (ButtonType buttonType : root.getButtonTypes()) {
ButtonBase button = (ButtonBase) root.lookupButton(buttonType);
button.setOnAction(evt -> {
root.setUserData(buttonType);
dialogStage.close();
});
}
root.getScene().setRoot(new Group());
Scene scene = new Scene(root);
dialogStage.setScene(scene);
dialogStage.initModality(Modality.APPLICATION_MODAL);
dialogStage.setAlwaysOnTop(true);
dialogStage.setResizable(false);
dialogStage.showAndWait();
}catch(Exception e){
}
// Optional<ButtonType> result = Optional.ofNullable((ButtonType) root.getUserData());
}
示例3: save
import javafx.scene.control.Alert; //導入依賴的package包/類
private void save(DSSDocument signedDocument) {
FileChooser fileChooser = new FileChooser();
fileChooser.setInitialFileName(signedDocument.getName());
MimeType mimeType = signedDocument.getMimeType();
ExtensionFilter extFilter = new ExtensionFilter(mimeType.getMimeTypeString(), "*." + MimeType.getExtension(mimeType));
fileChooser.getExtensionFilters().add(extFilter);
File fileToSave = fileChooser.showSaveDialog(stage);
if (fileToSave != null) {
try {
FileOutputStream fos = new FileOutputStream(fileToSave);
Utils.copy(signedDocument.openStream(), fos);
Utils.closeQuietly(fos);
} catch (Exception e) {
Alert alert = new Alert(AlertType.ERROR, "Unable to save file : " + e.getMessage(), ButtonType.CLOSE);
alert.showAndWait();
return;
}
}
}
示例4: displayFinalScore
import javafx.scene.control.Alert; //導入依賴的package包/類
private void displayFinalScore(ScoreEvent event) {
unsubscribeEvents();
double finalScore = event.getScorer().getScore();
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Game Over");
if ( finalScore == 0 ) {
alert.setContentText("Game ends in a draw.");
alert.showAndWait();
return;
}
String message;
if ( finalScore > 0 )
message = "Black";
else
message = "White";
finalScore = Math.abs(finalScore);
message += " wins by " + Double.toString(finalScore) + " points.";
alert.setContentText(message);
alert.showAndWait();
}
示例5: removeMemberAction
import javafx.scene.control.Alert; //導入依賴的package包/類
private void removeMemberAction(Event e) {
MemberView selected = memberTable.selectionModelProperty().get().getSelectedItem();
if (selected != null) {
Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to transfert " + organization.getName() + "'s ownership to "+ selected.getUsername() + " ?\n");
Optional<ButtonType> result = conf.showAndWait();
if (result.isPresent() && result.get().equals(ButtonType.OK)) {
try {
organization.removeMember(selected.getId());
} catch (JSONException | WebApiException | IOException | HttpException e1) {
ErrorUtils.getAlertFromException(e1).show();
forceUpdateMemberList();
e1.printStackTrace();
}
}
}
}
示例6: btnConfirmar_onAction
import javafx.scene.control.Alert; //導入依賴的package包/類
@FXML
void btnConfirmar_onAction(ActionEvent event) {
DepartamentoEntity ent;
if (novo) {
ent = new DepartamentoEntity();
} else {
ent = (DepartamentoEntity) tbvDepartamentos.getSelectionModel().getSelectedItem();
}
ent.setNome(txtNovoNomeDep.getText());
ent.setSigla(txtNovaSiglaDep.getText());
ent.setChefe((ServidorEntity) chbChefeDep.getSelectionModel().getSelectedItem());
DepartamentoException exc = (DepartamentoException) departamento.save(ent);
if (exc == null) {
Alertas.exibirAlerta(Alert.AlertType.INFORMATION, "Sucesso", "Departamento Salvo", "Departamento Salvo com Sucesso");
habilitarEdicao(false);
inicializarForm();
tbpDepartamento.getSelectionModel().select(tabConsultarDepartamento);
} else {
Alertas.exibirAlerta(Alert.AlertType.INFORMATION, "Erro", "Erro ao Salvar Departamento", "Dados Inconsistentes, favor revisar");
}
}
示例7: searchAction
import javafx.scene.control.Alert; //導入依賴的package包/類
private void searchAction(Event e) {
String query = queryField.getText();
searchList.clear();
try {
List<Member> orgaMemberList = organization.getMemberList();
ArrayList<MemberView> result = new ArrayList<>(organization.getWsp().searchMembers(query, 0, RESULT_SIZE).stream().map(m -> new MemberView(m)).collect(Collectors.toList()));
result.forEach(mv -> {
if (!orgaMemberList.stream().anyMatch(m -> m.getId() == mv.getId())) {
searchList.add(mv);
}
});
resultCount.setText(getResultCountText(searchList.size()));
} catch (JSONException | IOException | HttpException | WebApiException e1) {
new Alert(AlertType.ERROR, "Error while fetching member list. " + e1.getClass() + " : " + e1.getMessage()).show();
e1.printStackTrace();
}
}
示例8: btnProximo_onAction
import javafx.scene.control.Alert; //導入依賴的package包/類
@FXML
void btnProximo_onAction(ActionEvent event) {
String string = getDadosTabVisualizar();
if (string.length() > 0) {
Alert alerta = new Alert(AlertType.INFORMATION);
alerta.setTitle("AlphaLab");
alerta.setHeaderText("Dados de Requisitos");
alerta.setContentText(string);
alerta.show();
} else {
tabVisualizar.setDisable(true);
tabPreencherDados.setDisable(false);
tbpDados.getSelectionModel().select(tabPreencherDados);
texLaboratorio.setText(cmbLaboratorio.getValue().getNome());
if (hbxHorarios.getChildren() != null)
hbxHorarios.getChildren().clear();
criarNovasReservas();
hbxHorarios.getChildren().addAll(buildBoxHorario());
cmbProfessor.requestFocus();
}
}
示例9: saveOnExit
import javafx.scene.control.Alert; //導入依賴的package包/類
public void saveOnExit() {
if (!taNoteText.getText().equals(this.note.getText())) {
if (!JGMRConfig.getInstance().isDontAskMeToSave()) {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Save notes?");
alert.setHeaderText("Would you like to save your notes?");
ButtonType save = new ButtonType("Save");
ButtonType dontaskmeagain = new ButtonType("Don't ask me again");
ButtonType dontsave = new ButtonType("Don't save", ButtonData.CANCEL_CLOSE);
alert.getButtonTypes().setAll(save, dontaskmeagain, dontsave);
Optional<ButtonType> result = alert.showAndWait();
if(result.get() == save){
save();
}else if(result.get() == dontaskmeagain){
JGMRConfig.getInstance().setDontAskMeToSave(true);
save();
}
} else {
save();
}
}
}
示例10: mnuUndo
import javafx.scene.control.Alert; //導入依賴的package包/類
@FXML
private void mnuUndo(ActionEvent event) {
Stage SettingsStage = (Stage) btnSignOut.getScene().getWindow();
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Action Failed");
alert.setHeaderText("Undo Function Works Only From \"Make A Transaction\" and \"History\" Window");
alert.setContentText("Press \"OK\" to go to \"Make A Transaction\" window");
alert.setX(SettingsStage.getX() + 60);
alert.setY(SettingsStage.getY() + 170);
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK){
(new TabAccess()).setTabName("tabGetMoney"); //name of which Tab should open
(new GoToOperation()).goToMakeATransaction(SettingsStage.getX(), SettingsStage.getY());
SettingsStage.close();
}
}
示例11: setCorrectUpdateStatus
import javafx.scene.control.Alert; //導入依賴的package包/類
private void setCorrectUpdateStatus() {
updatesPane.getChildren().clear();
LOGGER.info("Checking for updates...");
if (updateChecker == null) {
LOGGER.info("Error while checking for updates.");
updatesPane.getChildren().add(checkFailed);
} else if (updateChecker.isNewerVersionAvailable()) {
LOGGER.info("Newer version available: v{}. Current version: v{}.", updateChecker.getLatestVersion(), appConfig.getAppVersion());
updatesPane.getChildren().add(newVersion);
tooltipArea.setOnMouseClicked((e) -> {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setContentText(String.format(INFO_TEMPLATE, appConfig.getAppVersion(), updateChecker.getLatestVersion()));
alert.show();
});
}
}
示例12: archiveSource
import javafx.scene.control.Alert; //導入依賴的package包/類
@FXML
private void archiveSource(ActionEvent event) {
try {
source.archiveSource(sourcecmboArchive.getValue());
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Message");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText(sourcecmboArchive.getValue()+ " is Archived Successfully");
Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
confirmationMsg.setX(SettingsStage.getX() + 200);
confirmationMsg.setY(SettingsStage.getY() + 170);
confirmationMsg.showAndWait();
tabSourceInitialize();
} catch (Exception e) {}
}
示例13: unarchiveSource
import javafx.scene.control.Alert; //導入依賴的package包/類
@FXML
private void unarchiveSource(ActionEvent event) {
try {
source.unarchiveSource(sourcecmboUnArchive.getValue());
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Message");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText(sourcecmboUnArchive.getValue()+ " is Unarchived Successfully");
Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
confirmationMsg.setX(SettingsStage.getX() + 200);
confirmationMsg.setY(SettingsStage.getY() + 170);
confirmationMsg.showAndWait();
tabSourceInitialize();
} catch (Exception e) {}
}
示例14: createSector
import javafx.scene.control.Alert; //導入依賴的package包/類
@FXML
private void createSector(ActionEvent event) {
if ((sectortxtSourceName.getText()).length() == 0 || countWords(sectortxtSourceName.getText()) == 0) {
sectorlblWarningMsg.setText("Write a Sector Name Please");
} else {
sectorlblWarningMsg.setText("");
sector.createSector(sectortxtSourceName.getText());
advancedSector.createSectorToAddList(sectortxtSourceName.getText());
Alert confirmationMsg = new Alert(AlertType.INFORMATION);
confirmationMsg.setTitle("Message");
confirmationMsg.setHeaderText(null);
confirmationMsg.setContentText("Sector "+sectortxtSourceName.getText()+ " created successfully");
Stage SettingsStage = (Stage) btnDashboard.getScene().getWindow();
confirmationMsg.setX(SettingsStage.getX() + 200);
confirmationMsg.setY(SettingsStage.getY() + 170);
confirmationMsg.showAndWait();
tabSectorInitialize();
}
}
示例15: changeLocaleAndReload
import javafx.scene.control.Alert; //導入依賴的package包/類
public void changeLocaleAndReload(String locale){
saveCurrentProject();
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Confirmation Dialog");
alert.setHeaderText("This will take effect after reboot");
alert.setContentText("Are you ok with this?");
Optional<ButtonType> result = alert.showAndWait();
if (result.get() == ButtonType.OK){
// ... user chose OK
try {
Properties props = new Properties();
props.setProperty("locale", locale);
File f = new File(getClass().getResource("../bundles/Current.properties").getFile());
OutputStream out = new FileOutputStream( f );
props.store(out, "This is an optional header comment string");
start(primaryStage);
}
catch (Exception e ) {
e.printStackTrace();
}
} else {
// ... user chose CANCEL or closed the dialog
}
}