本文整理匯總了Java中javax.swing.JOptionPane.showInternalConfirmDialog方法的典型用法代碼示例。如果您正苦於以下問題:Java JOptionPane.showInternalConfirmDialog方法的具體用法?Java JOptionPane.showInternalConfirmDialog怎麽用?Java JOptionPane.showInternalConfirmDialog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JOptionPane
的用法示例。
在下文中一共展示了JOptionPane.showInternalConfirmDialog方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeImageFile
import javax.swing.JOptionPane; //導入方法依賴的package包/類
private void writeImageFile(BufferedImage image, String path, String extension){
// --- Overwrite existing file ? ------------------
File writeFile = new File(path);
if (writeFile.exists()) {
String msgHead = "Overwrite?";
String msgText = "Overwrite existing file?";
int msgAnswer = JOptionPane.showInternalConfirmDialog(this, msgText, msgHead, JOptionPane.YES_NO_OPTION);
if (msgAnswer == JOptionPane.NO_OPTION) {
return;
}
}
try {
ImageIO.write(image, extension, writeFile);
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: exportAsImage
import javax.swing.JOptionPane; //導入方法依賴的package包/類
/**
* Export the current graph as image by using specified parameters.
*
* @param vv the VisualizationViewer
* @param file the current file to export to
*/
private void exportAsImage(BasicGraphGuiVisViewer<GraphNode, GraphEdge> vv, String path2File, String extension) {
// --- If the VisualizationViewer is null ---------
if (vv == null) {
return;
}
// --- Overwrite existing file ? ------------------
File writeFile = new File(path2File);
if (writeFile.exists()) {
String msgHead = "Overwrite?";
String msgText = "Overwrite existing file?";
int msgAnswer = JOptionPane.showInternalConfirmDialog(this, msgText, msgHead, JOptionPane.YES_NO_OPTION);
if (msgAnswer == JOptionPane.NO_OPTION) {
return;
}
}
// --- Lets go ! ----------------------------------
int width = vv.getSize().width;
int height = vv.getSize().height;
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
Graphics2D graphics = bi.createGraphics();
graphics.fillRect(0, 0, width, height);
boolean wasDoubleBuffered=vv.isDoubleBuffered();
vv.setDoubleBuffered(false);
vv.paint(graphics);
vv.paintComponents(graphics);
vv.setDoubleBuffered(wasDoubleBuffered);
try {
ImageIO.write(bi, extension, writeFile);
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: setLanguage
import javax.swing.JOptionPane; //導入方法依賴的package包/類
/**
* Enables to change the user language of the application
* If 'askUser' is set to false the changes will be done without user interaction.
*
* @param newLang => 'de', 'en', 'it', 'es' or 'fr' etc. is equal to the header line of the dictionary
* @param askUser
*/
public static void setLanguage(String newLang, boolean askUser) {
String newLine = getGlobalInfo().getNewLineSeparator();
if (askUser==true) {
// --- Do we have identical Languages -------------------
Integer newLangIndex = Language.getIndexOfLanguage(newLang);
if ( newLangIndex == Language.currLanguageIndex ) return;
// --- Ask user -----------------------------------------
String MsgHead = Language.translate("Anzeigesprache wechseln?");
String MsgText = Language.translate(
"Möchten Sie die Anzeigesprache wirklich umstellen?" + newLine +
"Die Anwendung muss hierzu neu gestartet und Projekte" + newLine +
"von Ihnen neu geöffnet werden.");
Integer MsgAnswer = JOptionPane.showInternalConfirmDialog( Application.getMainWindow().getContentPane(), MsgText, MsgHead, JOptionPane.YES_NO_OPTION);
if (MsgAnswer==1) return;
}
// --- Stop Agent.GUI ---------------------------------------
if (stopAgentGUI()==false) return;
// --- Switch Language --------------------------------------
System.out.println("=> " + Language.translate("Sprachumstellung zu") + " '" + newLang + "'.");
Language.changeApplicationLanguageTo(newLang);
// --- Restart application ----------------------------------
startAgentGUI();
}
示例4: stopAskUserBefore
import javax.swing.JOptionPane; //導入方法依賴的package包/類
/**
* Asks the user to shutdown Jade.
* @return true, if the user answered 'yes'
*/
public boolean stopAskUserBefore() {
if (this.isMainContainerRunning()==true && Application.getMainWindow()!=null) {
String title = Language.translate("JADE wird zur Zeit ausgeführt!");
String message = Language.translate("Möchten Sie JADE nun beenden?");
Integer answer = JOptionPane.showInternalConfirmDialog( Application.getMainWindow().getContentPane(), message, title, JOptionPane.YES_NO_OPTION);
if (answer==1) return false; // --- NO,just exit
// --- Stop the JADE-Platform -------------------
this.stop();
}
return true;
}
示例5: doClose
import javax.swing.JOptionPane; //導入方法依賴的package包/類
/**
* 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();
}
}
示例6: startAgent
import javax.swing.JOptionPane; //導入方法依賴的package包/類
/**
* Starts an agent as specified
*
* @param agentName the agent name
* @param agentClass the class of the agent
* @param startArguments the start arguments for the agent
* @param inContainer the container name
*/
public void startAgent(String agentName, Class<? extends Agent> agentClass, Object[] startArguments, String inContainer) {
// --- Was the system already started? ----------------------
if (this.isMainContainerRunning()==false) {
String msgHead = Language.translate("JADE wurde noch nicht gestartet!");
String msgText = Language.translate("Möchten Sie JADE nun starten und fortfahren?");
int msgAnswer = JOptionPane.showInternalConfirmDialog( Application.getMainWindow().getContentPane(), msgText, msgHead, JOptionPane.YES_NO_OPTION);
if (msgAnswer==JOptionPane.NO_OPTION) return; // --- NO,just exit
// --- Start the JADE-Platform -------------------------------
if (this.start() == false) {
// --- Abort if JADE was not successfully started --------
return;
}
}
// --- Get the AgentContainer -------------------------------
AgentContainer agentContainer = this.getContainer(inContainer);
if (agentContainer==null) {
// --- Do we have a remote container of that name? ------
if (this.startRemoteAgent(agentName, agentClass, startArguments, inContainer)==true) return;
// --- Start a new local container ----------------------
agentContainer = this.createAgentContainer(inContainer);
}
// --- Check if the agent name is already used --------------
Integer newAgentNoTmp = 0;
String newAgentNameTmp = agentName;
try {
agentContainer.getAgent(newAgentNameTmp, AID.ISLOCALNAME);
while (true) {
newAgentNoTmp++;
newAgentNameTmp = agentName + "-" + newAgentNoTmp;
agentContainer.getAgent(newAgentNameTmp, AID.ISLOCALNAME);
}
} catch (ControllerException ce) {
//ce.printStackTrace();
if (newAgentNoTmp>0) {
agentName = agentName + "-" + newAgentNoTmp;
}
}
// --- Start the actual agent -------------------------------
try {
Agent agent = (Agent) ClassLoadServiceUtility.newInstance(agentClass.getName());
agent.setArguments(startArguments);
AgentController agentController = agentContainer.acceptNewAgent(agentName, agent);
agentController.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}