Java Code Examples for javax.swing.JOptionPane.YES_OPTION

The following are Jave code examples for showing how to use YES_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: QN-ACTR-Release   File: InputPanel.java   View Source Code Vote up 6 votes
public void gotFocus() {
	// Chiedere a utente se cancellare tutto
	if (model.getMatrix() != null) {
		System.out.println("MODEL");
		if (JOptionPane.showConfirmDialog(this, "This operation resets all data. Continue ?", "WARNING", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
			model.resetModel();
			resetOnNew();
			((JWatWizard) getParentWizard()).setEnableButton("Solve", false);
		} else {
			parent.setLastPanel();
		}
	} else {
		((JWatWizard) getParentWizard()).setEnableButton("Solve", false);
	}
	parent.setCurrentPanel(WORKLOAD_INPUT_PANEL);
}
 
Example 2
Project: MuralEscolar   File: CadastroProfessor.java   View Source Code Vote up 6 votes
private void BTNcadastroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTNcadastroActionPerformed
    // TODO add your handling code here:
    String msg = "Deseja realmente cadastrar?";
    String title = "Cadastro de Professor";
    int reply = JOptionPane.showConfirmDialog(null, msg, title, JOptionPane.YES_NO_OPTION);
    if (reply == JOptionPane.YES_OPTION)
    {
        // Incrementar Banco de Dados
        Professor prof = new Professor();
        ProfessorController pc = new ProfessorController();
        
        prof.setNome(TXTnomeProf.getText());
        prof.setSiape(TXTsiape.getText());
        prof.setEmail(TXTemailProf.getText());
        prof.setCpf(TXTcpf.getText());
        prof.setSenha("padrao");
        
        JOptionPane.showMessageDialog(null, pc.inserir(prof));
    }
}
 
Example 3
Project: ramus   File: BranchView.java   View Source Code Vote up 6 votes
public void addChildBranch() {
    int row = table.getSelectedRow();
    if (row < 0)
        return;
    Node node = (Node) table.getPathForRow(row).getLastPathComponent();
    String message = GlobalResourcesManager
            .getString("BranchCreationWarning");
    if (node.branch.getChildren().size() > 0)
        message = GlobalResourcesManager
                .getString("BranchNodeCreationWarniong");
    if (JOptionPane.showConfirmDialog(framework.getMainFrame(), message,
            UIManager.getString("OptionPane.titleText"),
            JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION)
        return;
    String s = JOptionPane.showInputDialog(framework.getMainFrame(),
            GlobalResourcesManager.getString("BranchCreationReason"),
            GlobalResourcesManager.getString("BranchCreationReason"),
            JOptionPane.QUESTION_MESSAGE);
    if (s == null)
        return;
    int type = node.branch.getType() - 1;
    if (node.branch.getChildren().size() > 0) {
        type = getMaxType(type, (Node) branchModel.getRoot());
    }
    engine.createBranch(node.branch.getBranchId(), s, type + 1, "core");
}
 
Example 4
Project: SER316-Dresden   File: ResourceTypePanel.java   View Source Code Vote up 6 votes
/**
 * Delete a resource type and update the list.
 * @param e
 */
void deleteB_actionPerformed(ActionEvent e) {
    MimeType mt = (MimeType) typesList.getSelectedValue();
    int n =
        JOptionPane.showConfirmDialog(
            App.getFrame(),
            Local.getString("Delete resource type")
                + "\n'"
                + mt.getLabel()
                + "'\n"
                + Local.getString("Are you sure?"),
            Local.getString("Delete resource type"),
            JOptionPane.YES_NO_OPTION);
    if (n != JOptionPane.YES_OPTION)
        return;
    MimeTypesList.removeMimeType(mt.getMimeTypeId());
    CurrentStorage.get().storeMimeTypesList();
    this.initTypesList();
}
 
Example 5
Project: sic-public   File: NewAlerta.java   View Source Code Vote up 6 votes
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // Agregar
    alerta=new AlertaInternacional(txtTitulo.getText(),jcbImportancia.getSelectedIndex(),txtDescripcion.getText(),jcbUbicacion.getSelectedItem().toString());
    alerta.insertarEnDB();
    mf.alertas.add(alerta);//try catch
    //mf.setTxtArea( mf.getTxtArea()+"\n"+alerta.toString());
    
    int opt=showOptionDialog(null, "¿Desea crear mas alertas?","Mas alertas",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
        switch (opt) {
            case JOptionPane.YES_OPTION:
                txtTitulo.requestFocus();
                break;
            case JOptionPane.NO_OPTION:
                this.dispose();
                break;
            case JOptionPane.CANCEL_OPTION:
                break;
            default:
                break;
        }
}
 
Example 6
Project: Cognizant-Intelligent-Test-Scripter   File: ProjectTree.java   View Source Code Vote up 6 votes
private void deleteScenarios() {
    List<ScenarioNode> scenarioNodes = getSelectedScenarioNodes();
    if (!scenarioNodes.isEmpty()) {
        int option = JOptionPane.showConfirmDialog(null,
                "<html><body><p style='width: 200px;'>"
                + "Are you sure want to delete the following Scenarios?<br>"
                + scenarioNodes
                + "</p></body></html>",
                "Delete Scenario",
                JOptionPane.YES_NO_OPTION);
        if (option == JOptionPane.YES_OPTION) {
            LOGGER.log(Level.INFO, "Delete Scenarios approved for {0}; {1}",
                    new Object[]{scenarioNodes.size(), scenarioNodes});
            for (ScenarioNode scenarioNode : scenarioNodes) {
                deleteTestCases(Collections.list(scenarioNode.children()));
                scenarioNode.getScenario().delete();
                getTreeModel().removeNodeFromParent(scenarioNode);
            }
        }
    }
}
 
Example 7
Project: brModelo   File: EditorTexto.java   View Source Code Vote up 6 votes
private void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
    File arq = util.Dialogos.ShowDlgSaveAsAny(this.getRootPane(), "");
    if (arq == null) {
        return;
    }
    if (arq.exists()) {
        if (util.Dialogos.ShowMessageConfirm(getRootPane(), Editor.fromConfiguracao.getValor("Controler.MSG_QUESTION_REWRITE")) != JOptionPane.YES_OPTION) {
            return;
        }
    }
    try {
        FileWriter fw = new FileWriter(arq.getAbsoluteFile(), true);
        TextArea.write(fw);
    } catch (IOException iOException) {
        util.BrLogger.Logger("ERROR_DIAGRAMA_SAVE_ANY", iOException.getMessage());
    }
}
 
Example 8
Project: jmt   File: Mediator.java   View Source Code Vote up 6 votes
/**
 * 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;
}
 
Example 9
Project: sumo   File: BatchAnalysisGUI.java   View Source Code Vote up 5 votes
@Override
protected void succeeded(Object result) {
    if (JOptionPane.showConfirmDialog(null, "Do you want to open the kml master file?") == JOptionPane.YES_OPTION) {
        try {
            Desktop.getDesktop().open(new File(output + "/master.kml"));
        } catch (IOException ex) {
        	logger.error(ex.getMessage(),ex);
        }
    }
}
 
Example 10
Project: JavaGraph   File: PropertiesTable.java   View Source Code Vote up 5 votes
/**
 * Creates and shows a confirmation dialog for continuing the current
 * edit.
 */
private boolean showContinueDialog(String value) {
    int response = JOptionPane.showConfirmDialog(PropertiesTable.this,
        getContinueQuestion(value),
        null,
        JOptionPane.YES_NO_OPTION);
    return response == JOptionPane.YES_OPTION;
}
 
Example 11
Project: jaer   File: TargetLabeler.java   View Source Code Vote up 5 votes
synchronized public void doSaveLocations() {
    if (warnSave) {
        int ret = JOptionPane.showConfirmDialog(chip.getAeViewer().getFilterFrame(), "Really overwrite " + lastFileName + " ?", "Overwrite warning", JOptionPane.WARNING_MESSAGE);
        if (ret != JOptionPane.YES_OPTION) {
            log.info("save canceled");
            return;
        }
    }
    File f = new File(lastFileName);
    saveLocations(new File(lastFileName));
}
 
Example 12
Project: Wilmersdorf_SER316   File: EventsPanel.java   View Source Code Vote up 5 votes
void removeEventB_actionPerformed(ActionEvent e) {
		String msg;
		net.sf.memoranda.Event ev;

		if(eventsTable.getSelectedRows().length > 1) 
			msg = Local.getString("Remove") + " " + eventsTable.getSelectedRows().length 
				+ " " + Local.getString("events") + "\n" + Local.getString("Are you sure?");
		else {
			ev = (net.sf.memoranda.Event) eventsTable.getModel().getValueAt(
                eventsTable.getSelectedRow(),
                EventsTable.EVENT);
			msg = Local.getString("Remove event") + "\n'" 
				+ ev.getText() + "'\n" + Local.getString("Are you sure?");
		}

        int n =
            JOptionPane.showConfirmDialog(
                App.getFrame(),
                msg,
                Local.getString("Remove event"),
                JOptionPane.YES_NO_OPTION);
        if (n != JOptionPane.YES_OPTION) return;

        for(int i=0; i< eventsTable.getSelectedRows().length;i++) {
			ev = (net.sf.memoranda.Event) eventsTable.getModel().getValueAt(
                  eventsTable.getSelectedRows()[i], EventsTable.EVENT);
        EventsManager.removeEvent(ev);
		}
        eventsTable.getSelectionModel().clearSelection();
/*        CurrentStorage.get().storeEventsManager();
        eventsTable.refresh();
        EventsScheduler.init();
        parentPanel.calendar.jnCalendar.updateUI();
        parentPanel.updateIndicators();
*/ saveEvents();  
  }
 
Example 13
Project: ramus   File: StreamsTabView.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
    int i = table.getSelectedRow();
    if (i < 0)
        return;
    List<Row> rows = new ArrayList<Row>();

    for (int j : table.getSelectedRows()) {
        rows.add(data.get(table.convertRowIndexToModel(j)));
    }

    long[] ls = new long[rows.size()];
    for (int j = 0; j < ls.length; j++)
        ls[j] = rows.get(j).getElementId();

    DeleteStatusList list = framework.getAccessRules()
            .getElementsDeleteStatusList(ls);
    if (list.size() > 0) {
        if (!StatusMessageFormat.deleteElements(list, null, framework))
            return;
    } else {
        if (JOptionPane.showConfirmDialog(table, GlobalResourcesManager
                        .getString("DeleteActiveElementsDialog.Warning"),
                GlobalResourcesManager
                        .getString("ConfirmMessage.Title"),
                JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
            return;
    }

    streams.startUserTransaction();

    for (Row row : rows) {
        streams.deleteRow(row);

    }

    streams.commitUserTransaction();
}
 
Example 14
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 15
Project: sbc-qsystem   File: PComplexService.java   View Source Code Vote up 5 votes
private void listOfListsKeyPressed(
    java.awt.event.KeyEvent evt) {//GEN-FIRST:event_listOfListsKeyPressed
    if ((evt.getKeyCode() == KeyEvent.VK_DELETE || evt.getKeyCode() == KeyEvent.VK_BACK_SPACE)
        && listOfLists.getSelectedIndex() != -1) {
        if (JOptionPane.showConfirmDialog(this,
            locMes("del1") + " \"" + ((DefaultListModel) (listOfLists.getModel()))
                .get(listOfLists.getSelectedIndex()) + "\"?", locMes("del2"),
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)
            != JOptionPane.YES_OPTION) {
            return;
        }
        ((DefaultListModel) (listOfLists.getModel())).remove(listOfLists.getSelectedIndex());
        saveState();
    }
}
 
Example 16
Project: brModelo   File: Dialogos.java   View Source Code Vote up 4 votes
public static boolean ShowMessageConfirmYES(Component parente, String txtAdicional) {
    return (ShowMessageConfirm(parente, txtAdicional) == JOptionPane.YES_OPTION);
}
 
Example 17
Project: KernelHive   File: MainFrameController.java   View Source Code Vote up 4 votes
/**
 * 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);
	}
}
 
Example 18
Project: SER316-Munich   File: ProjectsPanel.java   View Source Code Vote up 4 votes
void ppDeleteProject_actionPerformed(ActionEvent e) {
	String msg;
	Project prj;
	Vector toremove = new Vector();
	if (prjTablePanel.projectsTable.getSelectedRows().length > 1)
		msg =
			Local.getString("Delete")
				+ " "
				+ prjTablePanel.projectsTable.getSelectedRows().length
				+ " "
				+ Local.getString("projects")
				+ "\n"
				+ Local.getString("Are you sure?");
	else {
		prj = prjTablePanel.getSelectedProject();
		msg =
			Local.getString("Delete project")
				+ " '"
				+ prj.getTitle()
				+ "'.\n"
				+ Local.getString("Are you sure?");
	}

	int n =
		JOptionPane.showConfirmDialog(
			App.getFrame(),
			msg,
			Local.getString("Delete project"),
			JOptionPane.YES_NO_OPTION);
	if (n != JOptionPane.YES_OPTION)
		return;

	for (int i = 0;
		i < prjTablePanel.projectsTable.getSelectedRows().length;
		i++) {
		prj =
			(net.sf.memoranda.Project) prjTablePanel
				.projectsTable
				.getModel()
				.getValueAt(
				prjTablePanel.projectsTable.getSelectedRows()[i],
				ProjectsTablePanel.PROJECT);
		toremove.add(prj.getID());
	}
	for (int i = 0; i < toremove.size(); i++) {
		ProjectManager.removeProject((String) toremove.get(i));
	}
	CurrentStorage.get().storeProjectManager();
	prjTablePanel.projectsTable.clearSelection();
	prjTablePanel.updateUI();
	setMenuEnabled(false);
}
 
Example 19
Project: school-game   File: StatementEditorPanel.java   View Source Code Vote up 4 votes
@Override
public void actionPerformed(ActionEvent event)
{

    if (event.getSource() == displayModeNothing)
    {
        saveDisplayMode(DisplayModeEnum.NOTHING);
    }
    else if (event.getSource() == displayModePlayerOnly)
    {
        saveDisplayMode(DisplayModeEnum.PLAYER_ONLY);
    }
    else if (event.getSource() == displayModePlayerAndCharacter)
    {
        saveDisplayMode(DisplayModeEnum.PLAYER_AND_CHARACTER);
    }
    else if (event.getSource() == displayModeCharacter)
    {
        saveDisplayMode(DisplayModeEnum.CHARACTER);
    }
    else if (event.getSource() == displayModeTwoCharacters)
    {
        saveDisplayMode(DisplayModeEnum.TWO_CHARACTERS);
    }
    else if (event.getSource() == displayPositionSwap)
    {
        swapPosition();
    }
    else if (event.getSource() == displayTalking)
    {
        saveTalking();
    }
    else if (event.getSource() == displayCharacter1)
    {
        saveCharacter1();
    }
    else if (event.getSource() == displayCharacter2)
    {
        saveCharacter2();
    }
    else if (event.getSource() == soundTextField)
    {
        saveSound();
    }
    else if (event.getSource() == saveButton)
    {
        saveSound();
    }
    else if (event.getSource() == removeButton && canRemove)
    {
        int result = JOptionPane.showConfirmDialog(this, "Achtung!\n" +
                "Wollen Sie wirklich dieses Statement löschen?", "Statement löschen", JOptionPane.YES_NO_OPTION);

        if (result == JOptionPane.YES_OPTION)
        {
            statementNode.getDialog().getStatement().remove(statementNode.getStatement());
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) statementNode.getParent();
            parent.remove(statementNode);
            editor.updateTree(parent);
        }
    }
    else if (event.getSource() == addTextButton)
    {
        String newText = "Neuer Text";

        int id = statementNode.getStatement().getTexts().getText().size();
        statementNode.getStatement().getTexts().getText().add(id, newText);

        statementNode.add(editor.new TextNode(this.statementNode.getDialog(), statementNode.getStatement(), newText, id));

        this.editor.updateTree(this.statementNode);
    }
}
 
Example 20
Project: rlc-analyser   File: MainFrame.java   View Source Code Vote up 4 votes
/**
 * Action that occurs after the process button is clicked. The method will
 * firstly check to see if the export button has previously been pressed. It
 * will then reset the DataStore and the current folder path. The method
 * then does a check of the folder input to ensure it satisfies the
 * requirements; returning if requirements are not met (not a folder or RLC
 * file).
 *
 * @param e
 *            - ActionEvent - on click process button.
 */
private void processButtonClick(final ActionEvent e) {
	String folderPath;
	folderPath = this.contentPanel.getFolderText().getText();

	final File file = new File(folderPath);

	// Check to see if user wants to export the file if they haven't already
	if (this.contentPanel.getResultsTab().getComponentCount() > 0 && !this.contentPanel.getExportStatus()) {
		final int result = JOptionPane.showConfirmDialog(	this,
		                                                 	"Processing new files will remove the previous analysis.\nDo you wish to export the data first?",
		                                                 	"Export", JOptionPane.YES_NO_OPTION);
		if (result == JOptionPane.YES_OPTION) {
			this.contentPanel.getExportButton().doClick();
		}
	}

	try {
		if (folderPath == null || folderPath.isEmpty() || !file.exists() || !file.isDirectory()) {
			if (file.isFile() && !file.getName().endsWith(".rlc")) {
				this.contentPanel.errorBadFileRLCConsole();
				System.err.println(
						"[ERROR] : Selected item was not a folder or an rlc file. Only folders or single rlc files are acceptable");
				return;
			}
		}
	} catch (final Exception e1) {
		e1.printStackTrace();
		System.err.println("[ERROR] : The file was not accepted for some reason");
		JOptionPane.showMessageDialog(this, "Oops, something went wrong. Please try that again.");
	}

	// Save folder name
	this.defaultProperties.setProperty("RLCAnalyser.folderName", folderPath);
	saveDefaults();
	this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

	this.contentPanel.processButtonUIFeatures();

	final RlcProcessTask rlcProcessTask = new RlcProcessTask();
	rlcProcessTask.execute();
}