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


Java ButtonData類代碼示例

本文整理匯總了Java中javafx.scene.control.ButtonBar.ButtonData的典型用法代碼示例。如果您正苦於以下問題:Java ButtonData類的具體用法?Java ButtonData怎麽用?Java ButtonData使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ButtonData類屬於javafx.scene.control.ButtonBar包,在下文中一共展示了ButtonData類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: displayDeleteGameAlert

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
public static void displayDeleteGameAlert() {
    int index = -1;

    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setHeaderText(null);
    alert.setContentText("Are you sure you want to delete the selected games?");

    ButtonType deleteGame = new ButtonType("Delete Game(s)");
    ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(deleteGame, buttonTypeCancel);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == deleteGame){
        for (String g : selectedGamesString) {
            index = getGameIndex(g);
            gameList.getGameList().remove(index);
        }

        refreshGameList();
        deleteButton.setDisable(true);
    }
    else {
        // ... user chose CANCEL or closed the dialog
    }
}
 
開發者ID:Stevoisiak,項目名稱:Virtual-Game-Shelf,代碼行數:27,代碼來源:GameShelf.java

示例2: displayFirstRunAlert

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
void displayFirstRunAlert(){
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setGraphic(new ImageView(ClassLoader.getSystemResource("images/common/cloud.png").toExternalForm()));
    alert.setTitle("Hall of Fame cloud service");
    alert.setHeaderText("Create or login to a Hall of Fame account");
    alert.setContentText("Online account lets you sync the game state\nbetween devices and compare results\nto other players.\n\n");
    alert.initOwner(mGameStage);

    ButtonType buttonTypeOK = new ButtonType("Create/Login", ButtonData.OK_DONE);
    ButtonType buttonTypeDontAsk = new ButtonType("Don't ask again", ButtonData.NO);
    ButtonType buttonTypeLater = new ButtonType("Ask later", ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(buttonTypeOK, buttonTypeDontAsk, buttonTypeLater);

    Optional<ButtonType> result = alert.showAndWait();
    if(result.isPresent()) {
        if (result.get() == buttonTypeOK) {
            prefs.putBoolean("hofAsked", true);
            displayHallOfFame();
        } else if (result.get() == buttonTypeDontAsk) {
            prefs.putBoolean("hofAsked", true);
        }
    }

}
 
開發者ID:nwg-piotr,項目名稱:EistReturns,代碼行數:26,代碼來源:Utils.java

示例3: saveOnExit

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的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();
        }
    }
}
 
開發者ID:eternia16,項目名稱:javaGMR,代碼行數:24,代碼來源:TexteditorController.java

示例4: deleteInterview

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
public void deleteInterview(DescriptionEntretien interview){
	Alert alert = new Alert(AlertType.CONFIRMATION);
	alert.setTitle("Supression Entretien");
	alert.setHeaderText("Vous allez supprimer "+interview.getNom());
	
	ButtonType buttonTypeOne = new ButtonType("Valider");
	ButtonType buttonTypeCancel = new ButtonType("Annuler", ButtonData.CANCEL_CLOSE);

	alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeCancel);

	Optional<ButtonType> result = alert.showAndWait();
	if (result.get() == buttonTypeOne){
		main.getCurrentProject().getEntretiens().remove(interview);
		this.getTreeItem().getParent().getChildren().remove(this.getTreeItem());
	}
}
 
開發者ID:coco35700,項目名稱:uPMT,代碼行數:17,代碼來源:InterviewTreeView.java

示例5: FileSelection

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
public FileSelection(File parent) {
	DialogPane dialogPane = this.getDialogPane();
	dialogPane.setMaxWidth(1.7976931348623157E308D);
	this.directoryView = new CheckTreeView<>();
	this.directoryView.setMaxWidth(1.7976931348623157E308D);
	CheckBoxTreeItem<File> root = createTree(new CheckBoxTreeItem<>(parent));
	root.setExpanded(true);
	directoryView.setRoot(root);
	GridPane.setHgrow(this.directoryView, Priority.ALWAYS);
	GridPane.setFillWidth(this.directoryView, true);
	this.grid = new GridPane();
	this.grid.setHgap(10.0D);
	this.grid.setMaxWidth(1.7976931348623157E308D);
	this.grid.setAlignment(Pos.CENTER_LEFT);
	dialogPane.contentTextProperty().addListener((o) -> this.updateGrid());
	this.setTitle(ControlResources.getString("Dialog.confirm.title"));
	dialogPane.setHeaderText(ControlResources.getString("Dialog.confirm.header"));
	dialogPane.getStyleClass().add("text-input-dialog");
	dialogPane.getButtonTypes().addAll(new ButtonType[] { ButtonType.APPLY, ButtonType.CANCEL });
	this.updateGrid();
	this.setResultConverter((dialogButton) -> {
		ButtonBar.ButtonData data = dialogButton == null ? null : dialogButton.getButtonData();
		return data == ButtonData.APPLY ? this.getValues() : null;
	});
}
 
開發者ID:HearthProject,項目名稱:OneClient,代碼行數:26,代碼來源:FileSelection.java

示例6: displayIndex

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
private void displayIndex(Map<String, Double> resultIndex, String title, String header) {
    BaseDialog dialog = new BaseDialog(title, header);
    dialog.getDialogPane().setPrefSize(800, 600);
    dialog.getDialogPane().getButtonTypes().addAll(new ButtonType(Configuration.getBundle().getString("ui.actions.stats.close"), ButtonBar.ButtonData.CANCEL_CLOSE));

    // draw
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    final LineChart<String,Number> lineChart = new LineChart<>(xAxis, yAxis);
    lineChart.setTitle(title);
    lineChart.setLegendVisible(false);

    xAxis.setLabel(Configuration.getBundle().getString("ui.actions.stats.xaxis"));
    yAxis.setLabel(Configuration.getBundle().getString("ui.actions.readable.yaxis"));

    XYChart.Series<String, Number> series = new XYChart.Series();
    for(Map.Entry<String, Double> st:resultIndex.entrySet()) {
        series.getData().add(new XYChart.Data(st.getKey(), st.getValue()));
    }
    lineChart.getData().addAll(series);
    dialog.getDialogPane().setContent(lineChart);
    dialog.setResizable(true);
    dialog.showAndWait();
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:25,代碼來源:MenuController.java

示例7: showPopup

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
public static void showPopup()
{
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle("Information");
    alert.setHeaderText(
            Translation.LANG.getTranslation("alert.forge.reinstall.header") + Gui.mineIdeInfo.getForgeVersion());
    alert.setContentText(Translation.LANG.getTranslation("alert.forge.reinstall.content.line1") + "\n"
            + Translation.LANG.getTranslation("alert.forge.reinstall.content.line2"));

    ButtonType buttonForceUpdate = new ButtonType(Translation.LANG.getTranslation("button.forceUpdate"));
    ButtonType buttonCancel = new ButtonType(Translation.LANG.getTranslation("button.cancel"),
            ButtonData.CANCEL_CLOSE);

    alert.getButtonTypes().setAll(buttonForceUpdate, buttonCancel);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == buttonForceUpdate)
        ForgeWorkspace.getInstance().forceUpdate();
    else
    {
    }
}
 
開發者ID:Leviathan-Studio,項目名稱:MineIDE-UI,代碼行數:23,代碼來源:PopupForgeInstallation.java

示例8: queryPasswordHelper

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
@Nullable
private char[] queryPasswordHelper(Supplier<PasswordResult> query, boolean requery) {
	PasswordResult passwordResult;

	if (this.cancelAll) {
		passwordResult = PasswordResult.CANCEL;
	} else if (!requery && this.rememberedPassword != null) {
		passwordResult = new PasswordResult(ButtonType.YES, this.rememberedPassword, true);
	} else {
		passwordResult = PlatformHelper.runLater(query);
	}

	ButtonData dialogResultData = passwordResult.dialogResult().getButtonData();

	if (dialogResultData == ButtonData.YES) {
		this.cancelAll = false;
		this.rememberedPassword = (passwordResult.rememberPassword() ? passwordResult.password() : null);
	} else if (dialogResultData == ButtonData.NO) {
		this.cancelAll = false;
		this.rememberedPassword = null;
	} else {
		this.cancelAll = true;
		this.rememberedPassword = null;
	}
	return passwordResult.password();
}
 
開發者ID:hdecarne,項目名稱:certmgr,代碼行數:27,代碼來源:PasswordDialog.java

示例9: onCmdDeleteEntry

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
@SuppressWarnings("unused")
@FXML
void onCmdDeleteEntry(ActionEvent evt) {
	UserCertStoreEntry entry = getSelectedStoreEntry();

	if (entry != null) {
		Optional<ButtonType> confirmation = Alerts
				.message(AlertType.CONFIRMATION, StoreI18N.formatSTR_MESSAGE_CONFIRM_DELETE(entry)).showAndWait();

		if (confirmation.isPresent() && confirmation.get().getButtonData() == ButtonData.OK_DONE) {
			try {
				this.storeProperty.get().deleteEntry(entry.id());
				if (entry.equals(getSelectedStoreEntry())) {
					this.ctlStoreEntryView.getSelectionModel().clearSelection();
				}
			} catch (IOException e) {
				Alerts.unexpected(e).showAndWait();
			}
		}
		updateStoreEntryView();
	}
}
 
開發者ID:hdecarne,項目名稱:certmgr,代碼行數:23,代碼來源:StoreController.java

示例10: handleCloseApp

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
/**
 * Handler to close the application.
 *
 * @param event The event.
 */
@FXML
protected void handleCloseApp(ActionEvent event) {
    Alert closeDialog = new Alert(Alert.AlertType.CONFIRMATION);
    closeDialog.setTitle(I18n.getMsg("gui.confirm-exit"));
    closeDialog.setContentText(I18n.getMsg("gui.want-to-quit"));
    ButtonType confirm = new ButtonType(I18n.getMsg("gui.exit"));
    ButtonType cancel = new ButtonType(I18n.getMsg("gui.cancel"),
            ButtonData.CANCEL_CLOSE);
    closeDialog.getButtonTypes().setAll(confirm, cancel);
    Optional<ButtonType> res = closeDialog.showAndWait();
    if (res.isPresent() && res.get() == confirm) {
        Stage stage = (Stage) buttonClose.getScene().getWindow();
        stage.fireEvent(new WindowEvent(
                stage,
                WindowEvent.WINDOW_CLOSE_REQUEST
        ));
    }
}
 
開發者ID:gdi-by,項目名稱:downloadclient,代碼行數:24,代碼來源:Controller.java

示例11: setupButtons

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
private Node setupButtons(Map<TextFieldDescription, TextField> fields) {
		ButtonType loginButtonType = new ButtonType("Login", ButtonData.OK_DONE);
		getDialog().getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

		// Enable/Disable login button depending on whether a username was entered.
		Node loginButton = getDialog().getDialogPane().lookupButton(loginButtonType);
//		loginButton.setDisable(true);
		
		// Convert the result to a username-password-pair when the login button is clicked.
		getDialog().setResultConverter(dialogButton -> {
		    if (dialogButton == loginButtonType) {
		    	return DialogResult.newInstance(fields);
		    }
		    return null;
		});
		
		return loginButton;
	}
 
開發者ID:lucastanziano,項目名稱:JavaFX-Skeleton-DEPRECATED,代碼行數:19,代碼來源:LoginDialog.java

示例12: NBTVersionChooser

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
public NBTVersionChooser() {
	setTitle(translate("nbt_version_chooser.title"));
	setHeaderText(translate("nbt_version_chooser.header"));
	boxInputVersion = new ComboBox<>(FXCollections.observableArrayList(NBTVersion.values()));
	boxOutputVersion = new ComboBox<>(FXCollections.observableArrayList(NBTVersion.values()));
	GridPane grid = new GridPane();
	grid.add(new Label(translate("nbt_version_chooser.input_version")), 1, 1);
	grid.add(boxInputVersion, 2, 1);
	grid.add(new Label(translate("nbt_version_chooser.output_version")), 1, 2);
	grid.add(boxOutputVersion, 2, 2);
	getDialogPane().setContent(grid);
	getDialogPane().getButtonTypes().add(ButtonType.OK);
	getDialogPane().getButtonTypes().add(ButtonType.CANCEL);
	setResultConverter(button -> {
		if (button.getButtonData() == ButtonData.OK_DONE) {
			return new NBTVersionConfig(boxInputVersion.getValue(), boxOutputVersion.getValue());
		} else {
			return null;
		}
	});

	boxInputVersion.setValue(NBTVersion.defaultConfig.getInputVersion());
	boxOutputVersion.setValue(NBTVersion.defaultConfig.getOutputVersion());
}
 
開發者ID:to2mbn,項目名稱:maptranslator,代碼行數:25,代碼來源:NBTVersionChooser.java

示例13: setupDialog

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
private void setupDialog(Menu... menus) {
	this.setTitle("Hotkeys");
	this.getDialogPane().getStylesheets().add(getClass().getResource(STYLE).toString());
	this.initOwner(parent.getScene().getWindow());
	this.initModality(Modality.NONE);
	this.getDialogPane().setPrefWidth(WIDTH);
	setupContentGrid();
	this.setHeaderText("Hotkeys");
	setupContent(menus);

	getDialogPane().setContent(content);
	
	ButtonType close = new ButtonType("Close", ButtonData.CANCEL_CLOSE);
	this.getDialogPane().getButtonTypes().add(close);
	this.showingProperty().addListener((obj, oldV, newV) -> {
		MenuItem hotkey = menus[menus.length - 1].getItems().get(0);
		hotkey.setDisable(!hotkey.isDisable());
	});
}
 
開發者ID:ProgrammingLife2015,項目名稱:dnainator,代碼行數:20,代碼來源:HotkeyHelpDialog.java

示例14: setupDialog

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
private void setupDialog() {
	this.setTitle("About DNAinator");
	this.setResizable(true);
	this.getDialogPane().getStylesheets().add(getClass().getResource(STYLE).toString());
	this.initOwner(parent.getScene().getWindow());
	
	ImageView img = new ImageView();
	img.setImage(new Image(getClass().getResourceAsStream(LOGO)));
	this.setGraphic(img);
	readProperties();
	
	this.setHeaderText("DNAinator\nDNA network visualization tool");
	this.setContentText(contentText());
	
	ButtonType close = new ButtonType("Close", ButtonData.CANCEL_CLOSE);
	this.getDialogPane().getButtonTypes().add(close);
}
 
開發者ID:ProgrammingLife2015,項目名稱:dnainator,代碼行數:18,代碼來源:AboutDialog.java

示例15: CheckUnsaved

import javafx.scene.control.ButtonBar.ButtonData; //導入依賴的package包/類
private boolean CheckUnsaved()
{
	if (!_isUnsaved) return false;

	Alert alert = new Alert(AlertType.CONFIRMATION);
	ButtonType buttonYes = new ButtonType(LocalizationHandler.Get("Yes"));
	ButtonType buttonNo = new ButtonType(LocalizationHandler.Get("No"));
	ButtonType buttonCancel = new ButtonType(LocalizationHandler.Get("Cancel"), ButtonData.CANCEL_CLOSE);
	alert.setTitle(CommonExtensions.TitleAndVersionString(getClass()));
	alert.setHeaderText(LocalizationHandler.Get("NotSaved"));
	alert.setContentText(String.format(LocalizationHandler.Get("SaveChangesPrompt"), txtName.getText()));
	alert.getButtonTypes().setAll(buttonYes, buttonNo, buttonCancel);

	Optional<ButtonType> result = alert.showAndWait();

	ButtonType b = result.get();
	if (b == buttonYes)
	{
		Save();
	}

	return b == buttonCancel;
}
 
開發者ID:andrewsarnold,項目名稱:FlagMaker-2,代碼行數:24,代碼來源:MainWindowController.java


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