本文整理汇总了Java中javax.swing.JOptionPane.CLOSED_OPTION属性的典型用法代码示例。如果您正苦于以下问题:Java JOptionPane.CLOSED_OPTION属性的具体用法?Java JOptionPane.CLOSED_OPTION怎么用?Java JOptionPane.CLOSED_OPTION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.swing.JOptionPane
的用法示例。
在下文中一共展示了JOptionPane.CLOSED_OPTION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: closeApplication
private void closeApplication() {
int response = JOptionPane.showOptionDialog(myCP, "Exit AIMerger?", "Exit",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null,
JOptionPane.YES_OPTION);
switch (response) {
default:
// This should never happen
throw new IllegalArgumentException("not an option");
case JOptionPane.CLOSED_OPTION:
case JOptionPane.CANCEL_OPTION:
offerNewMerge();
break;
case JOptionPane.OK_OPTION:
System.exit(0);
break;
}
}
示例2: actionPerformed
public void actionPerformed(ActionEvent e) {
if (!isEnabled())
return;
TermOptions clonedTermOptions = termOptions.makeCopy();
TermOptionsPanel subPanel = new TermOptionsPanel();
subPanel.setTermOptions(clonedTermOptions);
JOptionPane optionPane = new JOptionPane(subPanel,
JOptionPane.PLAIN_MESSAGE,
JOptionPane.OK_CANCEL_OPTION
);
JDialog dialog = optionPane.createDialog(Terminal.this,
"NBTerm Options");
dialog.setVisible(true); // WILL BLOCK!
if (optionPane.getValue() == null)
return; // was closed at the window level
switch ((Integer) optionPane.getValue()) {
case JOptionPane.OK_OPTION:
System.out.printf("Dialog returned OK\n");
termOptions.assign(clonedTermOptions);
applyTermOptions(false);
termOptions.storeTo(prefs);
break;
case JOptionPane.CANCEL_OPTION:
System.out.printf("Dialog returned CANCEL\n");
break;
case JOptionPane.CLOSED_OPTION:
System.out.printf("Dialog returned CLOSED\n");
break;
default:
System.out.printf("Dialog returned OTHER: %s\n",
optionPane.getValue());
break;
}
}
示例3: getChosenSaveFile
public File getChosenSaveFile(){
JFileChooser fc = new JFileChooser(){
@Override
public void approveSelection(){
File f = getSelectedFile();
if(f.exists() && getDialogType() == SAVE_DIALOG){
int result = JOptionPane.showConfirmDialog(this,"The file exists, overwrite?","Existing file",JOptionPane.YES_NO_OPTION);
switch(result){
case JOptionPane.YES_OPTION:
super.approveSelection();
return;
case JOptionPane.NO_OPTION:
case JOptionPane.CLOSED_OPTION:
return;
}
}
super.approveSelection();
}
};
if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION)
return fc.getSelectedFile();
else
return null;
}
示例4: showConfirmDialog
public static int showConfirmDialog(
Component parent,
String title,
String heading,
String message,
int messageType,
Icon icon,
int optionType,
Object key,
String disableMsg)
{
final Object o = showDialog(parent, title, buildContents(heading, message),
messageType, icon, optionType, null, null, key, disableMsg);
if (o == null || !(o instanceof Integer))
return JOptionPane.CLOSED_OPTION;
else
return ((Integer) o).intValue();
}
示例5: prompt
public static String prompt(String label, String data, String[] list,
boolean asButtons) {
try {
if (!asButtons)
return JOptionPane.showInputDialog(label, data);
if (data != null)
list = TextFormat.splitChars(data, "|");
int i = JOptionPane.showOptionDialog(null, label, "Jmol prompt",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null,
list, list[0]);
// ESCAPE will close the panel with no option selected.
return (data == null ? "" + i : i == JOptionPane.CLOSED_OPTION ? "null"
: list[i]);
} catch (Throwable e) {
return "null";
}
}
示例6: offerNewMerge
private void offerNewMerge() {
int response = JOptionPane.showOptionDialog(myCP, "Projects Successfully Merged. "
+ "Would you like to merge more projects?", "Projects Merged", JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, null, JOptionPane.YES_OPTION);
switch (response) {
default:
// This should never happen
throw new IllegalArgumentException("not an option");
case JOptionPane.CLOSED_OPTION:
case JOptionPane.NO_OPTION:
closeApplication();
break;
case JOptionPane.YES_OPTION:
offerToMergeToNewProject();
break;
}
}
示例7: offerToMergeToNewProject
private void offerToMergeToNewProject() {
int response = JOptionPane.showOptionDialog(myCP, "Would you like one of the projects to merge"
+ " to be the project you just created?", "Merge More Projects", JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.YES_OPTION);
switch (response) {
default:
// This should never happen
throw new IllegalArgumentException("not an option");
case JOptionPane.CLOSED_OPTION:
closeApplication();
break;
case JOptionPane.NO_OPTION:
resetAIMerger(null);
break;
case JOptionPane.YES_OPTION:
resetAIMerger(mergeProjectPath);
break;
}
}
示例8: offerNewMerge
private void offerNewMerge() {
int response = JOptionPane.showOptionDialog(myCP, "Projects Successfully Merged. "
+ "Would you like to merge more projects?", "Projects Merged", JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE, null, null, JOptionPane.YES_OPTION);
switch (response) {
default:
// This should never happen
throw new IllegalArgumentException("not an option");
case JOptionPane.CLOSED_OPTION:
case JOptionPane.NO_OPTION:
closeApplication();
break;
case JOptionPane.YES_OPTION:
offerToMergeToNewProject();
break;
}
}
示例9: offerToMergeToNewProject
private void offerToMergeToNewProject() {
int response = JOptionPane.showOptionDialog(myCP, "Would you like one of the projects to merge"
+ "to be the project you just created?", "Merge More Projects", JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE, null, null, JOptionPane.YES_OPTION);
switch (response) {
default:
// This should never happen
throw new IllegalArgumentException("not an option");
case JOptionPane.CLOSED_OPTION:
closeApplication();
break;
case JOptionPane.NO_OPTION:
resetAIMerger(null);
break;
case JOptionPane.YES_OPTION:
resetAIMerger(mergeProjectPath);
break;
}
}
示例10: closeApplication
private void closeApplication() {
int response = JOptionPane.showOptionDialog(myCP, "Exit AIMerger?", "Exit",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, null,
JOptionPane.YES_OPTION);
switch (response) {
default:
// This should never happen
throw new IllegalArgumentException("not an option");
case JOptionPane.CLOSED_OPTION:
case JOptionPane.CANCEL_OPTION:
offerNewMerge();
break;
case JOptionPane.OK_OPTION:
System.exit(0);
break;
}
}
示例11: addLink
@SuppressWarnings("unchecked")
private void addLink(int layer, V src, V dest) {
boolean addConstraint = true;
E edge = edgeFactory.create();
while (addConstraint) {
new AddConstraintDialog((NetworkEntity<AbstractConstraint>) edge, layer, GUI.getInstance(),
new Dimension(300, 150));
// if a resource/demand has been added
if (edge.get().size() > 0) {
addConstraint = false;
@SuppressWarnings("rawtypes")
Network net = scenario.getNetworkStack()
.getLayer(layer);
if ((net instanceof SubstrateNetwork && ((SubstrateNetwork) net)
.addEdge((SubstrateLink) edge, (SubstrateNode) src,
(SubstrateNode) dest))
|| (net instanceof VirtualNetwork && ((VirtualNetwork) net)
.addEdge((VirtualLink) edge, (VirtualNode) src,
(VirtualNode) dest))) {
vv.updateUI();
} else {
throw new AssertionError("Adding link failed.");
}
} else {
int option = JOptionPane.showConfirmDialog(GUI.getInstance(),
"A " + (layer == 0 ? "Resource" : "Demand")
+ " must be added for the link to be created!",
"Create Node", JOptionPane.OK_CANCEL_OPTION);
if (option == JOptionPane.CANCEL_OPTION
|| option == JOptionPane.CLOSED_OPTION) {
addConstraint = false;
}
}
}
}
示例12: actionPerformed
@Override
public void actionPerformed(ActionEvent e) {
Runnable runner = new Runnable() {
@Override
public void run() {
TreePath[] paths = resourcesTree.getSelectionPaths();
if (paths == null) { return; }
if (paths.length > 10) {
Object[] possibleValues =
{ "Open the "+paths.length+" objects", "Don't open" };
int selectedValue =
JOptionPane.showOptionDialog(instance, "Do you want to open "
+paths.length+" objects in the central tabbed pane ?",
"Warning", JOptionPane.DEFAULT_OPTION,
JOptionPane.QUESTION_MESSAGE, null,
possibleValues, possibleValues[1]);
if (selectedValue == 1
|| selectedValue == JOptionPane.CLOSED_OPTION) {
return;
}
}
for (TreePath path : paths) {
if(path != null) {
Object value = path.getLastPathComponent();
value = ((DefaultMutableTreeNode)value).getUserObject();
if(value instanceof Handle) {
final Handle handle = (Handle)value;
SwingUtilities.invokeLater(new Runnable() { @Override
public void run() {
select(handle);
}});
}
}
}
}
};
Thread thread = new Thread(runner, "ShowSelectedResourcesAction");
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
示例13: setup
/**
* Start/end a game. Prompt to save if the game state has been
* modified since last save. Invoke {@link GameComponent#setup}
* on all registered {@link GameComponent} objects.
*/
public void setup(boolean gameStarting) {
if (!gameStarting && gameStarted && isModified()) {
switch (JOptionPane.showConfirmDialog(
GameModule.getGameModule().getFrame(),
Resources.getString("GameState.save_game_query"), //$NON-NLS-1$
Resources.getString("GameState.game_modified"), //$NON-NLS-1$
JOptionPane.YES_NO_CANCEL_OPTION)) {
case JOptionPane.YES_OPTION:
saveGame();
break;
case JOptionPane.CANCEL_OPTION:
case JOptionPane.CLOSED_OPTION:
return;
}
}
this.gameStarting = gameStarting;
if (!gameStarting) {
pieces.clear();
}
newGame.setEnabled(!gameStarting);
saveGame.setEnabled(gameStarting);
saveGameAs.setEnabled(gameStarting);
closeGame.setEnabled(gameStarting);
if (gameStarting) {
loadGame.putValue(Action.NAME,
Resources.getString("GameState.load_continuation"));
GameModule.getGameModule().getWizardSupport().showGameSetupWizard();
}
else {
loadGame.putValue(Action.NAME,
Resources.getString("GameState.load_game"));
GameModule.getGameModule().appendToTitle(null);
}
gameStarted &= this.gameStarting;
for (GameComponent gc : gameComponents) {
gc.setup(this.gameStarting);
}
gameStarted |= this.gameStarting;
lastSave = gameStarting ? saveString() : null;
}
示例14: setCallback
void setCallback(ConfirmationCallback callback)
throws UnsupportedCallbackException
{
this.callback = callback;
int confirmationOptionType = callback.getOptionType();
switch (confirmationOptionType) {
case ConfirmationCallback.YES_NO_OPTION:
optionType = JOptionPane.YES_NO_OPTION;
translations = new int[] {
JOptionPane.YES_OPTION, ConfirmationCallback.YES,
JOptionPane.NO_OPTION, ConfirmationCallback.NO,
JOptionPane.CLOSED_OPTION, ConfirmationCallback.NO
};
break;
case ConfirmationCallback.YES_NO_CANCEL_OPTION:
optionType = JOptionPane.YES_NO_CANCEL_OPTION;
translations = new int[] {
JOptionPane.YES_OPTION, ConfirmationCallback.YES,
JOptionPane.NO_OPTION, ConfirmationCallback.NO,
JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL,
JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL
};
break;
case ConfirmationCallback.OK_CANCEL_OPTION:
optionType = JOptionPane.OK_CANCEL_OPTION;
translations = new int[] {
JOptionPane.OK_OPTION, ConfirmationCallback.OK,
JOptionPane.CANCEL_OPTION, ConfirmationCallback.CANCEL,
JOptionPane.CLOSED_OPTION, ConfirmationCallback.CANCEL
};
break;
case ConfirmationCallback.UNSPECIFIED_OPTION:
options = callback.getOptions();
/*
* There's no way to know if the default option means
* to cancel the login, but there isn't a better way
* to guess this.
*/
translations = new int[] {
JOptionPane.CLOSED_OPTION, callback.getDefaultOption()
};
break;
default:
throw new UnsupportedCallbackException(
callback,
"Unrecognized option type: " + confirmationOptionType);
}
int confirmationMessageType = callback.getMessageType();
switch (confirmationMessageType) {
case ConfirmationCallback.WARNING:
messageType = JOptionPane.WARNING_MESSAGE;
break;
case ConfirmationCallback.ERROR:
messageType = JOptionPane.ERROR_MESSAGE;
break;
case ConfirmationCallback.INFORMATION:
messageType = JOptionPane.INFORMATION_MESSAGE;
break;
default:
throw new UnsupportedCallbackException(
callback,
"Unrecognized message type: " + confirmationMessageType);
}
}
示例15: showYesNo
/**
* wyświetlenie zapytanie tak, nie
*
* @param title - tytuł okienka
* @param message - komunikat
* @return wybrana odpowiedź
*/
static public int showYesNo(String title, String message) {
int result = showConfirmDialog(message, title, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
return result == JOptionPane.CLOSED_OPTION ? NO : result;
}