本文整理匯總了Java中javafx.scene.control.ButtonType類的典型用法代碼示例。如果您正苦於以下問題:Java ButtonType類的具體用法?Java ButtonType怎麽用?Java ButtonType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ButtonType類屬於javafx.scene.control包,在下文中一共展示了ButtonType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onActionAbout
import javafx.scene.control.ButtonType; //導入依賴的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: loadAllEntities
import javafx.scene.control.ButtonType; //導入依賴的package包/類
private void loadAllEntities() {
int i = 0;
entities.clear();
for (Iterator<T> it = currentQueryList.fullIterator(); it.hasNext();) {
T entity = it.next();
entities.add(new EntityListEntry<T>().setEntity(entity));
i++;
if (i >= 500) {
LOGGER.warn("Warning after {}. Total: {}.", i, entities.size());
Optional<ButtonType> result = new Alert(Alert.AlertType.WARNING, "Already loaded " + entities.size() + " Entities.\nContinue loading?", ButtonType.CANCEL, ButtonType.YES).showAndWait();
if (!result.isPresent() || result.get() != ButtonType.YES) {
break;
}
i = 0;
}
}
buttonNext.setDisable(!currentQueryList.hasNextLink());
buttonDelete.setDisable(true);
}
示例3: removeAction
import javafx.scene.control.ButtonType; //導入依賴的package包/類
private void removeAction(Event e) {
Alert conf = new Alert(AlertType.CONFIRMATION, "Do you really want to delete this organization ?\n"
+ "Every server and member association will be lost.");
Optional<ButtonType> result = conf.showAndWait();
if (result.isPresent() && result.get().equals(ButtonType.OK)) {
try {
wsp.removeOrganization(orgas.selectionModelProperty().get().getSelectedItem().getOrganization());
forceOrganizationListRefresh();
App.getCurrentInstance().refreshWSPTabs();
} catch(Exception e1) {
ErrorUtils.getAlertFromException(e1).show();
}
}
}
示例4: won
import javafx.scene.control.ButtonType; //導入依賴的package包/類
/**
* A játék megnyerése esetén hívjuk a függvényt (ha kiürült minden kocsi)
* Üzenetet küld, hogy teljesítettük a pályát, a következő pályára lép
*/
public void won() {
if (winMedia != null) {
winMedia.seek(Duration.ZERO);
winMedia.play();
}
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Train Simulator 2017");
alert.setHeaderText(null);
alert.setContentText("Gratulálunk, nyertél!");
ButtonType nextButton = new ButtonType("Következő pálya");
alert.getButtonTypes().setAll(nextButton);
alert.showAndWait();
mapManager.nextMap();
startGame();
}
示例5: mnuUndo
import javafx.scene.control.ButtonType; //導入依賴的package包/類
@FXML
private void mnuUndo(ActionEvent event) {
Stage DashboardStage = (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(DashboardStage.getX() + 60);
alert.setY(DashboardStage.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(DashboardStage.getX(), DashboardStage.getY());
DashboardStage.close();
}
}
示例6: mnuUndo
import javafx.scene.control.ButtonType; //導入依賴的package包/類
@FXML
private void mnuUndo(ActionEvent event) {
Stage AboutStage = (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(AboutStage.getX() + 60);
alert.setY(AboutStage.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(AboutStage.getX(), AboutStage.getY());
AboutStage.close();
}
}
示例7: setup
import javafx.scene.control.ButtonType; //導入依賴的package包/類
private void setup() {
ProjectConfig config = ProjectConfig.getLast();
Dialog<ProjectConfig> dialog = new Dialog<>();
//dialog.initModality(Modality.APPLICATION_MODAL);
dialog.setResizable(true);
dialog.setTitle("UID Setup");
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
Node okButton = dialog.getDialogPane().lookupButton(ButtonType.OK);
UidSetupPane setupPane = new UidSetupPane(config, dialog.getOwner(), okButton);
dialog.getDialogPane().setContent(setupPane);
dialog.setResultConverter(button -> button == ButtonType.OK ? config : null);
dialog.showAndWait().ifPresent(newConfig -> {
setupPane.updateConfig();
if (!newConfig.isValid()) return;
newConfig.saveAsLast();
});
}
示例8: onClickPageClose
import javafx.scene.control.ButtonType; //導入依賴的package包/類
@FXML
private void onClickPageClose(ActionEvent event) {
if (this.rootTagElement == null) {
return;
}
final Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Saving?");
alert.setContentText("Do you want to save your latest changes?");
alert.getButtonTypes().clear();
alert.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
final ButtonType result = alert.showAndWait().orElse(ButtonType.CANCEL);
if (result == ButtonType.YES) {
save();
}
if (result != ButtonType.CANCEL) {
this.tags_view.setRoot(null);
this.file_save.setDisable(true);
this.rootTagElement = null;
this.openFile = null;
}
}
示例9: changeLocaleAndReload
import javafx.scene.control.ButtonType; //導入依賴的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
}
}
示例10: setMainASMFile
import javafx.scene.control.ButtonType; //導入依賴的package包/類
@Override
public void setMainASMFile()
{
ASMFile activeFile = getActiveFile();
if (activeFile == null)
{
Dialogues.showActionFailedDialogue("No file is selected!");
return;
}
Project activeProject = activeFile.getProject();
String message = "The file \"" + activeFile.getName()
+ "\" will be used as the main file for the project \""
+ activeProject.getName() + "\"";
Optional<ButtonType> result = Dialogues.showConfirmationDialogue(message);
if (result.get() == ButtonType.OK)
{
int index = activeProject.indexOf(activeFile);
Collections.swap(activeProject, 0, index);
}
}
示例11: canAppend
import javafx.scene.control.ButtonType; //導入依賴的package包/類
public boolean canAppend(File file) {
EditorDockable dockable = findEditorDockable(file);
if (dockable == null) {
return true;
}
if (!dockable.getEditor().isDirty()) {
return true;
}
Optional<ButtonType> result = FXUIUtils.showConfirmDialog(DisplayWindow.this,
"File " + file.getName() + " being edited. Do you want to save the file?", "Save Module", AlertType.CONFIRMATION,
ButtonType.YES, ButtonType.NO);
ButtonType option = result.get();
if (option == ButtonType.YES) {
save(dockable.getEditor());
return true;
}
return false;
}
示例12: delete
import javafx.scene.control.ButtonType; //導入依賴的package包/類
@Override public Optional<ButtonType> delete(Optional<ButtonType> option) {
if (!option.isPresent() || option.get() != FXUIUtils.YES_ALL) {
option = FXUIUtils.showConfirmDialog(null, "Do you want to delete the entry `" + entry.getName() + "`?", "Confirm",
AlertType.CONFIRMATION, ButtonType.YES, ButtonType.NO, FXUIUtils.YES_ALL, ButtonType.CANCEL);
}
if (option.isPresent() && (option.get() == ButtonType.YES || option.get() == FXUIUtils.YES_ALL)) {
GroupResource parent = (GroupResource) getParent();
parent.deleteEntry(this);
try {
Group.updateFile(parent.getSuite());
Event.fireEvent(parent, new ResourceModificationEvent(ResourceModificationEvent.UPDATE, parent));
} catch (IOException e) {
e.printStackTrace();
return option;
}
}
return option;
}
示例13: show
import javafx.scene.control.ButtonType; //導入依賴的package包/類
public void show() {
paneController.load();
ResourceBundle i18n = toolBox.getI18nBundle();
Dialog<ButtonType> dialog = new Dialog<>();
dialog.setTitle(i18n.getString("prefsdialog.title"));
dialog.setHeaderText(i18n.getString("prefsdialog.header"));
GlyphsFactory gf = MaterialIconFactory.get();
Text settingsIcon = gf.createIcon(MaterialIcon.SETTINGS, "30px");
dialog.setGraphic(settingsIcon);
dialog.getDialogPane()
.getButtonTypes()
.addAll(ButtonType.OK, ButtonType.CANCEL);
dialog.getDialogPane()
.setContent(paneController.getRoot());
dialog.getDialogPane()
.getStylesheets()
.addAll(toolBox.getStylesheets());
Optional<ButtonType> buttonType = dialog.showAndWait();
buttonType.ifPresent(bt -> {
if (bt == ButtonType.OK) {
paneController.save();
}
});
}
示例14: loadPlugin
import javafx.scene.control.ButtonType; //導入依賴的package包/類
@FXML
private void loadPlugin() {
FileChooser chooser = new FileChooser();
chooser.setTitle("Choose a plugin");
chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Plugin", "*.jar"));
List<File> files = chooser.showOpenMultipleDialog(root.getScene().getWindow());
if (files == null) {
return;
}
files.forEach(f -> {
try {
// TODO save this in user preferences
PluginLoader.getDefault().loadPluginJar(f.toURI());
} catch (IOException | IllegalArgumentException e) {
log.log(Level.WARNING, "Could not load jar", e);
// TODO improve the dialog; use something like what GRIP has
Alert alert = new Alert(Alert.AlertType.ERROR, null, ButtonType.OK);
alert.setTitle("Could not load plugins");
alert.setHeaderText("Plugins in " + f.getName() + " could not be loaded");
alert.setContentText("Error message:\n\n " + e.getMessage());
alert.showAndWait();
}
});
}
示例15: newFile
import javafx.scene.control.ButtonType; //導入依賴的package包/類
@FXML
public void newFile() {
Alert closeConfirmation = new Alert(
Alert.AlertType.CONFIRMATION,
"Create a new station?",
ButtonType.YES,
ButtonType.NO
);
closeConfirmation.setHeaderText("New station");
closeConfirmation.initModality(Modality.APPLICATION_MODAL);
closeConfirmation.initOwner(root.getScene().getWindow());
Optional<ButtonType> closeResponse = closeConfirmation.showAndWait();
if (ButtonType.YES.equals(closeResponse.get())) {
station = new Station();
updateEditors();
updateTitle();
}
}