当前位置: 首页>>代码示例>>Java>>正文


Java JOptionPane.CANCEL_OPTION属性代码示例

本文整理汇总了Java中javax.swing.JOptionPane.CANCEL_OPTION属性的典型用法代码示例。如果您正苦于以下问题:Java JOptionPane.CANCEL_OPTION属性的具体用法?Java JOptionPane.CANCEL_OPTION怎么用?Java JOptionPane.CANCEL_OPTION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.swing.JOptionPane的用法示例。


在下文中一共展示了JOptionPane.CANCEL_OPTION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveOrDiscardLastResults

public static boolean saveOrDiscardLastResults() {
    if (lastResults != null) {
        int ret = JOptionPane.showConfirmDialog
            (guiFrame,
             "The results of the last test will be "+
             "discarded if you continue!  Do you want "+
             "to save them?",
             "Discard last results?",
             JOptionPane.YES_NO_CANCEL_OPTION);
        if (ret == JOptionPane.CANCEL_OPTION) {
            return false;
        } else if (ret == JOptionPane.YES_OPTION) {
            if (saveResults()) {
                lastResults = null;
            } else {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:J2DBench.java

示例2: save

public void save() throws IOException {
	initChooser();
	int ok = JOptionPane.NO_OPTION;
	if( file!=null ) {
		ok = JOptionPane.showConfirmDialog(
			(JFrame)getTopLevelAncestor(),
			"overwrite "+file.getName()+"?",
			"overwrite?",
			JOptionPane.YES_NO_CANCEL_OPTION);
		if( ok==JOptionPane.CANCEL_OPTION) return;
		chooser.setSelectedFile( file);
	}
	if( ok==JOptionPane.NO_OPTION) {
		ok = chooser.showSaveDialog((JFrame)getTopLevelAncestor());
		if( ok==chooser.CANCEL_OPTION) return;
		file = chooser.getSelectedFile();
	}
	apply();
	String type = file.getName().substring(
		file.getName().indexOf(".")+1).toLowerCase();
	if( !type.equals("jpg") && !type.equals("png") && !type.equals("tif")) type="jpg";
	ImageIO.write( image, type, file);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:23,代码来源:ImageComponent.java

示例3: promptForName

@Override
protected String promptForName()
{
	final JValidatingTextField field = new JValidatingTextField(new JValidatingTextField.MaxLength(
		Term.MAX_TERM_VALUE_LENGTH), new JValidatingTextField.DisallowStr(TaxonomyConstants.TERM_SEPARATOR));
	String name = null;
	do
	{
		final int result = JOptionPane.showOptionDialog(this, field,
			CurrentLocale.get("com.tle.admin.gui.common.tree.editor.entername"), JOptionPane.OK_CANCEL_OPTION,
			JOptionPane.PLAIN_MESSAGE, null, null, null);
		if( result == JOptionPane.CANCEL_OPTION )
		{
			return null;
		}
		name = field.getText();
	}
	while( Check.isEmpty(name) || !isProposedNewNameValid(name) );

	return name.trim();
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:TermTree.java

示例4: checkForSave

/**
 * Shows a confirmation dialog to save before new model or exit operations
 * 
 * @param msg
 *            The message to display.
 * @return <code>true</code> - if the user select cancel button.
 */
public boolean checkForSave(String msg) {
	// Checks if there's an old graph to save
	if (data != null && data.isChanged()) {
		int resultValue = JOptionPane.showConfirmDialog(this, msg,
				"JABA - Warning", JOptionPane.YES_NO_CANCEL_OPTION,
				JOptionPane.WARNING_MESSAGE);
		if (resultValue == JOptionPane.YES_OPTION) {
			save();
			return true;
		}
		if (resultValue == JOptionPane.CANCEL_OPTION) {
			return true;
		}
	}
	return false;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:23,代码来源:JabaWizard.java

示例5: checkForSave

/**
 * Checks if there's an old graph to save. This methods is called when creates/closes/opens a graph.
 * @param msg The message to display.
 * @return <code>true</code> - whether the user accepts to save the graph, or he cancels the current action.
 */
public boolean checkForSave(String msg) {
	// Checks if there's an old graph to save
	if (model != null && model.toBeSaved()) {
		int resultValue = JOptionPane.showConfirmDialog(mainWindow, msg, "JMODEL - Warning", JOptionPane.YES_NO_CANCEL_OPTION,
				JOptionPane.WARNING_MESSAGE);
		if (resultValue == JOptionPane.YES_OPTION) {
			saveModel();
			return true;
		}
		if (resultValue == JOptionPane.CANCEL_OPTION) {
			return true;
		}
	}
	return false;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:20,代码来源:Mediator.java

示例6: checkForSave

/**
 * Checks if there's an old graph to save. This methods is called when creates/closes/opens a graph.
 * @param msg The message to display.
 * @return <code>true</code> - whether the user accepts to save the graph, or he cancels the current action.
 */
public boolean checkForSave(String msg) {
	// Checks if there's an old graph to save
	if (model != null && model.toBeSaved()) {
		int resultValue = JOptionPane.showConfirmDialog(mainWindow, msg, "JSIMgraph - Warning", JOptionPane.YES_NO_CANCEL_OPTION,
				JOptionPane.WARNING_MESSAGE);
		if (resultValue == JOptionPane.YES_OPTION) {
			saveModel();
			return true;
		}
		if (resultValue == JOptionPane.CANCEL_OPTION) {
			return true;
		}
	}
	return false;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:20,代码来源:Mediator.java

示例7: attemptToCloseWindow

protected void attemptToCloseWindow()
{
	boolean close = trySave(new GlassSwingWorker<Object>()
	{
		@Override
		public Object construct() throws Exception
		{
			tabManager.saveTabs();
			return null;
		}
	}) != JOptionPane.CANCEL_OPTION;

	if( close )
	{
		dialog.setVisible(false);
		dialog.dispose();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:SecurityTree.java

示例8: confirmCancel

/**
 * Creates and shows a confirmation dialog for abandoning the currently
 * edited graph.
 * @return {@code true} if the user did not cancel the action
 */
public boolean confirmCancel() {
    boolean result = true;
    if (isDirty()) {
        int answer = JOptionPane.showConfirmDialog(getDisplay(),
            String.format("%s '%s' has been modified. Save changes?",
                getResourceKind().getName(),
                getName()),
            null,
            JOptionPane.YES_NO_CANCEL_OPTION);
        if (answer == JOptionPane.YES_OPTION) {
            saveResource();
        }
        result = answer != JOptionPane.CANCEL_OPTION;
    }
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:21,代码来源:ResourceTab.java

示例9: 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;
			}
		}
	}
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:35,代码来源:MyEditingPopupGraphMousePlugin.java

示例10: confirmFileFormatWarning

protected boolean confirmFileFormatWarning(String warning,
		String dialogTitle) {
	System.out.println(warning);

	int answer = JOptionPane.showConfirmDialog(null, warning, dialogTitle,
			2, JOptionPane.WARNING_MESSAGE);

	if (answer == JOptionPane.CANCEL_OPTION) {
		clearGraph();
		return false;
	}
	return true;
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:13,代码来源:CxfNetwork.java

示例11: showOpenDialog

public static String showOpenDialog(java.awt.Component comp) {
	if( jdial==null )jdial = new JanusDialog();
	int ok = jdial.showDialog(comp);
	if( ok==JOptionPane.CANCEL_OPTION )return null;
	Janus j = new Janus(jdial.getDataID(), jdial.getLeg(), jdial.getSite(), jdial.getHole());
	return j.urlString();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:7,代码来源:Janus.java

示例12: actionPerformed

/**
 * {@inheritDoc}
 */
@Override
public void actionPerformed(ActionEvent e) {
    JTabbedPane pane = observer.getTabs();
    int i = pane.indexOfTabComponent(tab);
    JNotepadPPDocument editor = observer.getEditors().get(i);

    List<JNotepadPPDocument> editors = observer.getEditors();

    if (pane.getComponentCount() == 4) {
        return;
    }
    if (editor.isChanged()) {
        int answer = JOptionPane.showConfirmDialog(observer,
                lp.getString("saveMessage"), lp.getString("saveDialog"),
                JOptionPane.YES_NO_CANCEL_OPTION);

        if (answer == JOptionPane.YES_OPTION) {
            editor.saveDocument(false);
        } else if (answer == JOptionPane.CANCEL_OPTION) {
            return;
        }
    }

    pane.remove(i);
    editors.remove(i);
    int size = editors.size();

    if (i >= size) {
        observer.setActiveEditor(editors.get(size - 1));
        pane.setSelectedIndex(size - 1);
    } else {
        observer.setActiveEditor(editors.get(i));
        pane.setSelectedIndex(i);
    }
    observer.getActiveEditor().updateStatusBar();
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:39,代码来源:TabButtonAction.java

示例13: querySave

protected boolean querySave() throws IOException {
  switch (JOptionPane.showConfirmDialog(this, "Do you want to save these changes now?",
      "Unsaved Changes", JOptionPane.YES_NO_CANCEL_OPTION)) {
  case JOptionPane.YES_OPTION:
    saveTranslation();
    return true;
  case JOptionPane.NO_OPTION:
    reloadTranslation();
    return true;
  case JOptionPane.CANCEL_OPTION:
    return false;
  }
  return true;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:14,代码来源:TranslateWindow.java

示例14: doClose

/**
 * Does the close action.
 */
private void doClose() {
	
	if (this.hasChanged()==true) {
		// --- Data model has changed ! ---------------------------
		String diaTitle = Language.translate("Close Properties", Language.EN);
		String diaQuestion = null;
		if (this.graphController.getProject()!=null) {
			// --- Setup case -------------
			diaQuestion = Language.translate("Save changes to network model?", Language.EN);
		} else {
			// --- Execution case ---------
			diaQuestion = Language.translate("Save and send data model changes to agent(s)?", Language.EN);
		}

		// --- User request ---------------------------------------
		int diaAnswer = JOptionPane.showInternalConfirmDialog(this, diaQuestion, diaTitle, JOptionPane.YES_NO_CANCEL_OPTION);
		if (diaAnswer==JOptionPane.YES_OPTION) {
			if (this.graphController.getProject()!=null) {
				// --- Setup case -------------
				this.save();	
			} else {
				// --- Execution case ---------
				this.save(true);
			}
			this.setVisible(false);
			this.dispose();
			
		} else if (diaAnswer==JOptionPane.NO_OPTION){
			this.setVisible(false);
			this.dispose();
			
		} else if (diaAnswer==JOptionPane.CANCEL_OPTION){
			// --- Do nothing ---- 
		}
		
	} else {
		// --- Data model has NOT changed ! ---
		this.setVisible(false);
		this.dispose();
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:44,代码来源:BasicGraphGuiProperties.java

示例15: closeTab

/**
 * closes the selected tab
 *
 * @param tab {@link JTabPanel}
 */
public void closeTab(final JTabPanel tab) {
	JTabContent content;
	int index = -1;
	if (tab != null) {
		content = tab.getTabContent();
		for (int i = 0; i < frame.getWorkspacePane().getTabCount(); i++) {
			final Component c = frame.getWorkspacePane().getTabComponentAt(
					i);
			if (c.equals(tab)) {
				index = i;
				break;
			}
		}
	} else {
		index = frame.getWorkspacePane().getSelectedIndex();
		if (index != -1) {
			content = (JTabContent) frame.getWorkspacePane()
					.getComponentAt(index);
		} else {
			return;
		}
	}

	if (content != null) {
		content.onClose();
	}

	// TODO i18n
	if (content.isDirty()) {
		final int result = JOptionPane.showConfirmDialog(
				frame.getContentPane(),
				"The selected file has been modified. "
				+ "Do you wanto to save it?", "Save file?",
				JOptionPane.YES_NO_CANCEL_OPTION);
		if (result == JOptionPane.YES_OPTION) {
			final File f = content.getFile();
			if (f != null && f.exists()) {
				content.saveContent(f);
			} else {
				saveTabAs(tab);
			}
			frame.getWorkspacePane().removeTabAt(index);
		} else if (result == JOptionPane.NO_OPTION) {
			frame.getWorkspacePane().removeTabAt(index);
		} else if (result == JOptionPane.CANCEL_OPTION) {
		}
	} else {
		frame.getWorkspacePane().removeTabAt(index);
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:55,代码来源:MainFrameController.java


注:本文中的javax.swing.JOptionPane.CANCEL_OPTION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。