Java Code Examples for javax.swing.JOptionPane.NO_OPTION

The following are Jave code examples for showing how to use NO_OPTION of the javax.swing.JOptionPane class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: geomapapp   File: ImageComponent.java   View Source Code Vote up 7 votes
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);
}
 
Example 2
Project: JavaGraph   File: ConfigDialog.java   View Source Code Vote up 6 votes
/** Asks and attempts to save the current configuration, if it is dirty. */
boolean askSave() {
    if (!isDirty()) {
        return true;
    }
    int answer = JOptionPane.showConfirmDialog(this,
        String.format("Configuration '%s' has been modified. Save changes?", getSelectedName()),
        null,
        JOptionPane.YES_NO_CANCEL_OPTION);
    if (answer == JOptionPane.YES_OPTION) {
        saveConfig();
    } else if (answer == JOptionPane.NO_OPTION) {
        setDirty(false);
    }
    return answer != JOptionPane.CANCEL_OPTION;
}
 
Example 3
Project: Equella   File: ReloadHandler.java   View Source Code Vote up 6 votes
@Override
public void actionPerformed(ActionEvent e)
{
	if( reload.isSelected() )
	{
		int result = JOptionPane.showConfirmDialog(reload,
			CurrentLocale.get("com.dytech.edge.admin.wizard.reloadhandler.selecting"),
			CurrentLocale.get("com.dytech.edge.admin.wizard.reloadhandler.warning"), JOptionPane.YES_NO_OPTION,
			JOptionPane.WARNING_MESSAGE);

		if( result == JOptionPane.NO_OPTION )
		{
			reload.setSelected(false);
		}
	}
}
 
Example 4
Project: VASSAL-src   File: Deck.java   View Source Code Vote up 5 votes
private File getSaveFileName() {
  FileChooser fc = GameModule.getGameModule().getFileChooser();
  File sf = fc.getSelectedFile();
  if (sf != null) {
    String name = sf.getPath();
    if (name != null) {
      int index = name.lastIndexOf('.');
      if (index > 0) {
        name = name.substring(0, index) + ".sav"; //$NON-NLS-1$
        fc.setSelectedFile(new File(name));
      }
    }
  }

  if (fc.showSaveDialog(map.getView()) != FileChooser.APPROVE_OPTION)
    return null;

  File outputFile = fc.getSelectedFile();
  if (outputFile != null &&
      outputFile.exists() &&
      shouldConfirmOverwrite() &&
      JOptionPane.NO_OPTION ==
       JOptionPane.showConfirmDialog(GameModule.getGameModule().getFrame(),
        Resources.getString("Deck.overwrite", outputFile.getName()), Resources.getString("Deck.file_exists"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        JOptionPane.YES_NO_OPTION)) {
      outputFile = null;
  }

  return outputFile;
}
 
Example 5
Project: AgentWorkbench   File: ProjectWindow.java   View Source Code Vote up 5 votes
@Override
public ProjectCloseUserFeedback getUserFeedbackForClosingProject(String msgTitle, String msgText) {

	ProjectCloseUserFeedback userFeedback = null;
	int msgAnswer = JOptionPane.showConfirmDialog(Application.getMainWindow(), msgText, msgTitle, JOptionPane.YES_NO_CANCEL_OPTION);
	if (msgAnswer == JOptionPane.CANCEL_OPTION) {
		userFeedback = ProjectCloseUserFeedback.CancelCloseAction;
	} else if (msgAnswer == JOptionPane.YES_OPTION) {
		userFeedback = ProjectCloseUserFeedback.SaveProject;
	} else if (msgAnswer == JOptionPane.NO_OPTION) {
		userFeedback = ProjectCloseUserFeedback.DoNotSaveProject;
	}
	return userFeedback;
}
 
Example 6
Project: jaer   File: BiasgenFrame.java   View Source Code Vote up 5 votes
private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
	//        int ret=showInternalOptionDialog(
           //                Component parent,
           //                Object message,
           //                String title,
           //                int optionType,
           //                int messageType,
           //                Icon icon,
           //                Object[] options,
           //                Object initialValue
           //                )
           Object[] options = {"Yes, really exit JVM", "Just close window", "Cancel"};
           int ret = JOptionPane.showOptionDialog(
                   getContentPane(),
                   "Are you sure you want to exit (this will kill JVM and thus matlab if running from within matlab)?",
                   "Exit biasgen?",
                   JOptionPane.YES_NO_CANCEL_OPTION,
                   JOptionPane.WARNING_MESSAGE,
                   null,
                   options,
                   options[1]);
           if (ret == JOptionPane.YES_OPTION) {
               biasgen.close();
               System.exit(0);
           } else if (ret == JOptionPane.NO_OPTION) {
               biasgen.close();
               dispose();
           }
}
 
Example 7
Project: QN-ACTR-Release   File: InputPanel.java   View Source Code Vote up 5 votes
public boolean canGoBack() {
	if (JOptionPane.showConfirmDialog(this, "Are you sure want to go back to start screen ?", "Back operation", JOptionPane.YES_NO_OPTION,
			JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) {
		return false;
	}
	//Reset della finestra principale
	parent.resetScreen();
	return true;
}
 
Example 8
Project: jmt   File: LoadDemoPanel.java   View Source Code Vote up 5 votes
@Override
public boolean canGoBack() {
	if (JOptionPane.showConfirmDialog(this, "Are you sure you want to go back to start screen?", "Back operation", JOptionPane.YES_NO_OPTION,
			JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) {
		return false;
	}
	//Reset della finestra principale
	parent.resetScreen();
	return true;
}
 
Example 9
Project: jmt   File: InputPanel.java   View Source Code Vote up 5 votes
public boolean canGoBack() {
	if (JOptionPane.showConfirmDialog(this, "Are you sure you want to go back to start screen?", "Back operation", JOptionPane.YES_NO_OPTION,
			JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) {
		return false;
	}
	//Reset della finestra principale
	parent.resetScreen();
	return true;
}
 
Example 10
Project: jmt   File: InputPanel.java   View Source Code Vote up 5 votes
public boolean canGoBack() {
	if (JOptionPane.showConfirmDialog(this, "Are you sure you want to go back to start screen?", "Back operation", JOptionPane.YES_NO_OPTION,
			JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) {
		return false;
	}
	//Reset della finestra principale
	parent.resetScreen();
	return true;
}
 
Example 11
Project: Project-SADS   File: MainWindow.java   View Source Code Vote up 5 votes
/**
 * Check for unsaved changes in the Editor
 * 
 * @return whether the situation was resolved
 */
private boolean resolveUnsavedChanges()
{
	//check if any changes have not been saved
	if(unsavedChanges)
	{
		int option = JOptionPane.showConfirmDialog(frmStringSequenceAnalyzer, "There are unsaved changes. Would you like to save?", "Save?", JOptionPane.YES_NO_CANCEL_OPTION);
		switch(option)
		{
		case JOptionPane.YES_OPTION:
			//save the contents of editorArea
			save(currentBatch, editorArea.getText());
			unsavedChanges = false;
			break;
			
		case JOptionPane.NO_OPTION:
			//just continue with the opening procedure
			
			break;
			
		case JOptionPane.CANCEL_OPTION:
			//back out of opening a file
			return false;
		}
	}
	return true;
}
 
Example 12
Project: QN-ACTR-Release   File: InputPanel.java   View Source Code Vote up 5 votes
public boolean canGoBack() {
	if (JOptionPane.showConfirmDialog(this, "Are you sure want to go back to start screen ?", "Back operation", JOptionPane.YES_NO_OPTION,
			JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) {
		return false;
	}
	//Reset della finestra principale
	parent.resetScreen();
	return true;
}
 
Example 13
Project: QN-ACTR-Release   File: LoadDemoPanel.java   View Source Code Vote up 5 votes
@Override
public boolean canGoBack() {
	if (JOptionPane.showConfirmDialog(this, "Are you sure want to go back to start screen ?", "Back operation", JOptionPane.YES_NO_OPTION,
			JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION) {
		return false;
	}
	//Reset della finestra principale
	parent.resetScreen();
	return true;
}
 
Example 14
Project: incubator-netbeans   File: UiUtils.java   View Source Code Vote up 4 votes
public static boolean showMessageDialog(
        final String message,
        final String title,
        final MessageType messageType) {
    initLAF();
    
    boolean exitInstaller = false;
    
    switch (UiMode.getCurrentUiMode()) {
        case SWING:
            int intMessageType = JOptionPane.INFORMATION_MESSAGE;                               
            
            LogManager.logIndent("... show message dialog");
            LogManager.log("title: "+ title);
            LogManager.log("message: " + message);
            
            if (messageType == MessageType.WARNING) {
                intMessageType = JOptionPane.WARNING_MESSAGE;                
            } else if (messageType == MessageType.CRITICAL) {
                intMessageType = JOptionPane.ERROR_MESSAGE;
                exitInstaller = true;
            }
            
            if (messageType == MessageType.ERROR) {                    
                int result = JOptionPane.showOptionDialog(null,
                                    message,
                                    title,
                                    JOptionPane.YES_NO_OPTION,
                                    JOptionPane.ERROR_MESSAGE,
                                    null,
                                    null,
                                    JOptionPane.YES_OPTION);
                if (result == JOptionPane.NO_OPTION) {
                    exitInstaller = true;
                    LogManager.logUnindent("... user selected: NO");                        
                } else {
                    LogManager.logUnindent("... user selected: YES");
                }
            } else {
                JOptionPane.showMessageDialog(null, 
                        message, 
                        title, 
                        intMessageType);
            }
            
            LogManager.logUnindent("... dialog closed");
            break;
        case SILENT:
            LogManager.log(message);
            System.err.println(message);
            break;
    }
    
    return exitInstaller;
}
 
Example 15
Project: Ultraino   File: DialogUtils.java   View Source Code Vote up 4 votes
public static int getBooleanDialog(Component father, String title){
    int option = JOptionPane.showConfirmDialog(father,title);
    if ( option == JOptionPane.YES_OPTION) { return 1;}
    else if ( option == JOptionPane.NO_OPTION) { return 0;}
    else{ return -1;}
}
 
Example 16
Project: Snake-Ladder   File: Main.java   View Source Code Vote up 4 votes
public void inputName(){
	
     // Initialize variables

    	playerName = new String[playerPos];
    	
    		for(int i=0; i<playerPos; i++){

    			playerName[i] = "Player "+String.valueOf(i+1);

    		}

    // Input Names
    		int confirm = JOptionPane.showConfirmDialog(null, "Do you want Skip Names?", "Player!", JOptionPane.YES_NO_OPTION);
    		if(confirm == JOptionPane.NO_OPTION){
    			for(int i=0; i<playerPos; i++){
    			
    				try{
    				
    					//do{
    						playerName[i] = JOptionPane.showInputDialog("Enter Name of Player "+ String.valueOf(i+1)+" :");
    						JOptionPane.showMessageDialog(null, playerName[i]);
    				//	}while(playerName[i].equals(""));
    				}catch(Exception e){
    					JOptionPane.showMessageDialog(null, "Invalid name");
    					playerName[i] = "Player "+ String.valueOf(i+1);
    				}
    			}
    		}
    	
    		if(playerPos == 2){
    			// = Integer.parseInt(JOptionPane.showInputDialog("Enter No of players"));
    			lblP1.setText(playerName[0]);
    			lblP2.setText(playerName[1]);
    			
    			label_1.setVisible(false);
    			lblP3.setVisible(false);
    			p3score.setVisible(false);
    			
    			label_2.setVisible(false);
    			lblP4.setVisible(false);
    			p4score.setVisible(false);
    			
    		}
    		else if(playerPos == 3){
    			lblP1.setText(playerName[0]);
    			lblP2.setText(playerName[1]);
    			lblP3.setText(playerName[2]);
    			
    			label_2.setVisible(false);
    			lblP4.setVisible(false);
    			p4score.setVisible(false);
    			
    		}
    		else if(playerPos == 4){
    			lblP1.setText(playerName[0]);
    			lblP2.setText(playerName[1]);
    			lblP3.setText(playerName[2]);
    			lblP4.setText(playerName[3]);
    			

    		}
	
}
 
Example 17
Project: Equella   File: GroupDetailsPanel.java   View Source Code Vote up 4 votes
public void loadGroup(final TLEGroup group, final TreeUpdateName r)
{
	if( loadedGroup != null && group != null && loadedGroup.getId() == group.getId() )
	{
		return;
	}

	if( !changeDetector.hasDetectedChanges() )
	{
		loadDetails(group);
	}
	else
	{
		Object[] buttons = new Object[]{
				CurrentLocale.get("com.tle.admin.usermanagement.internal.groupdetailspanel.save"), //$NON-NLS-1$
				CurrentLocale.get("com.tle.admin.usermanagement.internal.groupdetailspanel.dontsave")}; //$NON-NLS-1$
		int results = JOptionPane.showOptionDialog(this,
			CurrentLocale.get("com.tle.admin.usermanagement.internal.groupdetailspanel.savemods"), //$NON-NLS-1$
			CurrentLocale.get("com.tle.admin.usermanagement.internal.groupdetailspanel.savegroup"), //$NON-NLS-1$
			JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, buttons, buttons[1]);

		if( results == JOptionPane.NO_OPTION )
		{
			loadDetails(group);
		}
		else if( results == JOptionPane.YES_OPTION )
		{
			new MyGlassSwingWorker<String>(this)
			{
				@Override
				public String doStuff()
				{
					return saveLoadedGroup();
				}

				@Override
				public void finished()
				{
					if( r != null && loadedGroup != null )
					{
						r.update(loadedGroup.getName());
					}
					loadDetails(group);
				}
			}.start();
		}
	}
}
 
Example 18
Project: Equella   File: UniversalControlModel.java   View Source Code Vote up 4 votes
@Override
public String doValidation(ClientService clientService)
{

	String error = Validation.hasTitle(this);
	if( error != null )
	{
		return error;
	}

	error = Validation.hasTarget(getControl());
	if( error != null )
	{
		return error;
	}

	UniversalControl control = getControl();
	@SuppressWarnings("unchecked")
	Set<String> types = (Set<String>) control.getAttributes().get("AttachmentTypes");
	if( Check.isEmpty(types) )
	{
		String[] buttons = {s("notype.confirm.yes"), s("notype.confirm.no")};

		final int choice = JOptionPane.showOptionDialog(getEditor(), s("notype.confirm.message"),
			s("notype.confirm.title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, buttons,
			buttons[0]);

		if( choice == JOptionPane.NO_OPTION )
		{
			return s("notype.confirm.no.message");
		}
		else if( choice == JOptionPane.YES_OPTION )
		{
			return null;
		}
	}

	List<UniversalPanelValidator> panels = getExtensions(Driver.instance().getPluginService()).getBeanList();
	for( UniversalPanelValidator upv : panels )
	{
		if( types.contains(upv.getValidatorType()) )
		{
			String validatePanel = upv.doValidation(control, clientService);
			if( !Check.isEmpty(validatePanel) )
			{
				return validatePanel;
			}
		}
	}

	return null;
}
 
Example 19
Project: jmt   File: Mediator.java   View Source Code Vote up 4 votes
public Mediator(final JmtJGraph graph, MainWindow mainWindow) {
	this.mainWindow = mainWindow;
	dialogFactory = new DialogFactory(mainWindow);
	cellFactory = new CellFactory(this);
	customizableDialogFactory = new CustomizableDialogFactory(mainWindow);

	if (Defaults.getAsBoolean("showDefaultTemplates")) {
		int result = JOptionPane.showConfirmDialog(mainWindow, "Would you like to download some recommended templates for JSIMGraph?");
		if (result == JOptionPane.YES_OPTION) {
			downloadDefaultTemplates();
		}
		if (result == JOptionPane.NO_OPTION) {
			Defaults.set("showDefaultTemplates", "false");
			Defaults.save();
		}
	}

	this.graph = graph;
	closeModel = new CloseModel(this);
	newModel = new NewModel(this);
	openHelp = new OpenHelp(this);
	openModel = new OpenModel(this);
	saveModel = new SaveModel(this);
	setConnect = new SetConnectState(this);
	actionCut = new ActionCut(this);
	actionCopy = new ActionCopy(this);
	actionPaste = new ActionPaste(this);
	actionDelete = new ActionDelete(this);
	setOptions = new SetOptions(this);
	setSelect = new SetSelectState(this);
	simulate = new Simulate(this);

	solveAnalitic = new SolveAnalytic(this);
	solveApp = new SolveApprox(this);

	undoManager = new GraphUndoManager();
	undoProxy = new UndoManagerProxy(undoManager);
	editUndo = new ActionUndo(this, undoManager);
	editRedo = new ActionRedo(this, undoManager);

	pauseSimulation = new PauseSimulation(this);
	stopSimulation = new StopSimulation(this);
	exit = new Exit(this);
	clipboard = new JmtClipboard(this);
	editDefaults = new EditDefaults(this);
	saveModelAs = new SaveModelAs(this);
	editSimParams = new EditSimParams(this);
	editPAParams = new EditPAParams(this);
	showResults = new ShowResults(this);

	useTemplate = new UseTemplate(this);
	downloadDefaultTemplates = new DownloadDefaultTemplates(this);

	about = new About(this);
	addBlockingRegion = new AddBlockingRegion(this);

	actionSetRight = new ActionSetRight(this);
	takeScreenShot = new TakeScreenShot(this);

	actionRotate = new ActionRotate(this);
	overlapping = new JmtOverlapping(this);

	editUserClasses = new EditUserClasses(this);
	editMeasures = new EditMeasures(this);
	switchToExactSolver = new SwitchToExactSolver(this);
	// Initialize new Component bar
	componentBar = new ComponentBar(this);
}
 
Example 20
Project: LanChatLite   File: MainGui.java   View Source Code Vote up 2 votes
/**
 * other party send "SFR - Send File Request"
 * asking me to receive the file,
 * if I click yes, then other party should give me the file
 * so, send GMF request to other party
 * and start TCP thread to receive file 
 * @param msg
 */
private void processSFR(String msg) {
    
	String l[] = msg.split("\\::");
	
	String otherHost = l[0];
	String filePath = l[1];		
	int fileSize = Integer.parseInt(l[2]);
	System.out.println("File length: " + fileSize);
	
	String otherIP = htblUsers.get(otherHost);
		
	Path p = Paths.get(filePath);
    String fileName = p.getFileName().toString();

    //System.out.println("filePath = " + filePath);
    //System.out.println("fileName = " + fileName);
      
	JDialog.setDefaultLookAndFeelDecorated(true);
    int response = JOptionPane.showConfirmDialog(null, 
    		"Do you want to receive file from " + otherHost + " ?",
    		"Receive File: " + fileName,
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    
    if (response == JOptionPane.NO_OPTION) {
      System.out.println("No button clicked");
      Utils.sendUdpMsg("GMF" + myHost + "::" + "" + "::" + "No file", otherIP, Config.UDP_PORT);
    } else if (response == JOptionPane.YES_OPTION) {
    
    System.out.println("Yes button clicked");  
    
 // parent component of the dialog
    JFrame parentFrame = new JFrame();
     
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Specify a file to save");   

    fileChooser.setSelectedFile(new File(System.getProperty("user.home") + File.separator  + fileName) ); 
    int userSelection = fileChooser.showSaveDialog(parentFrame);
     
    if (userSelection == JFileChooser.APPROVE_OPTION) {
        File fileToSave = fileChooser.getSelectedFile();
        
        
        
        String savePath = fileToSave.getAbsolutePath();
        System.out.println("Save as file: " + savePath);
        
        
        Config.TCP_PORT++;
        System.out.println("TCP Port : " +  Config.TCP_PORT );
	  	
	    new ReceiveFileThread(Config.TCP_PORT, savePath, fileSize).start();
	    Utils.sendUdpMsg("GMF" + myHost + "::" + Config.TCP_PORT + "::" + filePath, otherIP, Config.UDP_PORT);
    }
   
         
    } else if (response == JOptionPane.CLOSED_OPTION) {
      System.out.println("JOptionPane closed");
    }
}