Java 类javax.swing.JOptionPane 实例源码

项目:SkyDocs    文件:ProjectsFrame.java   
/**
 * Loads projects from the history.
 */

public final void loadHistory() {
    try {
        final File history = new File(Utils.getParentFolder(), Constants.FILE_GUI_HISTORY);
        if(!history.exists()) {
            return;
        }
        for(final String path : Files.readLines(history, StandardCharsets.UTF_8)) {
            final File projectData = new File(path, Constants.FILE_PROJECT_DATA);
            if(!projectData.exists()) {
                continue;
            }
            projectsModel.addElement(path);
        }
    }
    catch(final Exception ex) {
        ex.printStackTrace(guiPrintStream);
        ex.printStackTrace();
        JOptionPane.showMessageDialog(ProjectsFrame.this, String.format(Constants.GUI_DIALOG_ERROR_MESSAGE, ex.getMessage()), ex.getClass().getName(), JOptionPane.ERROR_MESSAGE);
    }
}
项目:3way_laboratorios    文件:MaiorNumero.java   
public static void main(String[] args) {

        int[] num = new int[10];
        int contador;
        int max = 0;
        int numerostotal = 3;

        // Pede ao usuário para digitar números
        for (contador = 0; contador < numerostotal; contador++) {
            num[contador] = Integer.parseInt(JOptionPane.showInputDialog("Entre com números até " + numerostotal + " no total"));

            // verifica se o número digitado é maior que max
            if (( contador == 0 ) || ( num[contador] < max ))
                max = num[contador];
        }

        // Mostra o maior número.
        JOptionPane.showMessageDialog(null, "O maior número é " + max);
    }
项目:ProjetoERP    文件:ClienteViewActionListener.java   
@Override
public void actionPerformed(ActionEvent e) {
    String action = e.getActionCommand();
    if (action.equals(Vars.PROP_NEW)) {
        ClientesCadastro clienteCadastro = new ClientesCadastro();
        if (VerificaFrame.verificaFrame(clientes.getPainel(), clienteCadastro)) {
            VerificaFrame.exibirFrame(clientes.getPainel(), clienteCadastro);
            clientes.addChild(clienteCadastro);
        }
    } else if (action.equals(Vars.PROP_REMOVE)) {
         JTable tabela = clientes.getTable();
       int cod = (int) tabela.getValueAt(tabela.getSelectedRow(), 1);
        br.com.secharpe.dao.ClienteDAO clDAO = new br.com.secharpe.dao.ClienteDAO();
        clDAO.delete(cod);
        clientes.refreshTable();
    } else if (action.equals(Vars.PROP_EDIT)) {
        JOptionPane.showMessageDialog(null, "W.I.P.");
    } else if (action.equals(Vars.PROP_CLOSE)) {
        clientes.dispose();
    }
}
项目:GroupK    文件:KhachHangDAL.java   
public static void InsertKhachHang(KhachHang kh) {
    String sql = "insert into KHACH_HANG values(?,?,?,?,?)";
    try {
        ps = DBconnect.getConnect().prepareStatement(sql);
        ps.setString(1, kh.getMaKH());
        ps.setString(2, kh.getTenKH());
        ps.setDate(3, kh.getBirth());
        ps.setString(4, kh.getDiaChi());
        ps.setString(5, kh.getPhone());

        ps.execute();
        JOptionPane.showMessageDialog(null, "Đã thêm khách hàng thành công!" , "Thông báo", 1);
    } catch(Exception e) {
        JOptionPane.showMessageDialog(null, "Khách hàng không được thêm" , "Thông báo", 1);
    }
}
项目:grade-buddy    文件:MainWindow.java   
/**
 * Executes the selection script.
 * @param submission The currently selected submission
 * @throws Exception See {@link Command#execute()}
 */
private void runScript(final Submission submission) throws Exception {
    Command c = new Command(
        new String[]{
            "sh",
            this.selectionScript.getAbsolutePath(),
            submission.directory().getAbsolutePath()
        }
    ).execute();
    if (c.result().exitCode() != 0) {
        System.out.println(c.result().outputStream().toString());
        System.err.println(c.result().errorStream().toString());
        JOptionPane.showMessageDialog(
            this,
            "Error executing script. Please read the error output.",
            "Error",
            JOptionPane.ERROR_MESSAGE
        );
    }
}
项目:Tarski    文件:EditorActions.java   
/**
 * @throws IOException
 *
 */
protected void openGD(BasicGraphEditor editor, File file,
        String gdText)
{
    mxGraph graph = editor.getGraphComponent().getGraph();

    // Replaces file extension with .mxe
    String filename = file.getName();
    filename = filename.substring(0, filename.length() - 4) + ".mxe";

    if (new File(filename).exists()
            && JOptionPane.showConfirmDialog(editor,
                    mxResources.get("overwriteExistingFile")) != JOptionPane.YES_OPTION)
    {
        return;
    }

    ((mxGraphModel) graph.getModel()).clear();
    mxGdCodec.decode(gdText, graph);
    editor.getGraphComponent().zoomAndCenter();
    editor.setCurrentFile(new File(lastDir + "/" + filename));
}
项目:jmt    文件:ClassesPanel.java   
private void setNumberOfClasses(int number) {
    classTable.stopEditing();

    if (number <= MAXCLASSES) {
        classes = number;
    } else {
        JOptionPane.showMessageDialog(this, "Sorry, jABA admits only up to " + MAXCLASSES + " classes", "jABA classes warning",
                JOptionPane.ERROR_MESSAGE);
        return;
    }

    classNames = ArrayUtils.resize(classNames, classes, null);
    makeNames();

    classTypes = ArrayUtils.resize(classTypes, classes, CLASS_CLOSED);
    classData = ArrayUtils.resize(classData, classes, 0.0);

    classTable.updateStructure();
    if (!deleting) {
        classOps.add(ListOp.createResizeOp(classes));
    }

    classSpinner.setValue(new Integer(classes));
    classTable.updateDeleteCommand();
}
项目:SimQRI    文件:WorkspaceManager.java   
/**
 * 
 * @param modelingProject the name of the selected modeling project
 * @return the list of all the report templates name that are available in the selected modeling project
 */
public static List<String> getTemplates(String modelingProject) { // For the SimulationManagementWindow (names)
    List<String> templatesName = new ArrayList<String>();
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(modelingProject);
    IFolder templatesFolder = project.getFolder("Report Templates");
    try {
        IResource[] folderContent = templatesFolder.members();
        for(IResource resource : folderContent) {
            if(resource.getType() == IFile.FILE && resource.getFileExtension().equals("rptdesign")) {
                templatesName.add(resource.getName());
            }
        }
    } catch (CoreException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "Error: " + e.getMessage() + "", "Error", JOptionPane.ERROR_MESSAGE);
    }
    return templatesName;
}
项目:VASSAL-src    文件:InviteCommand.java   
protected void executeCommand() {
  if (client instanceof NodeClient) {
    final int i = Dialogs.showConfirmDialog(
      GameModule.getGameModule().getFrame(),
      Resources.getString("Chat.invite_heading"), //$NON-NLS-1$
      Resources.getString("Chat.invite_heading"), //$NON-NLS-1$
      Resources.getString("Chat.invitation", player, room),  //$NON-NLS-1$
      JOptionPane.QUESTION_MESSAGE,
      null,
      JOptionPane.YES_NO_OPTION,
      "Invite"+playerId,  //$NON-NLS-1$
      Resources.getString("Chat.ignore_invitation") //$NON-NLS-1$
    );

    if (i == 0) {
      ((NodeClient) client).doInvite(playerId, room);
    }
  }
}
项目:sumo    文件:GeometricInteractiveVDSLayerModel.java   
public GeometricInteractiveVDSLayerModel(ILayer layer) {
    this.gl = ((EditGeometryVectorLayer) layer).getGeometriclayer();
    this.il = null;

    for (ILayer l : LayerManager.getIstanceManager().getLayers().keySet()) {
        if (l instanceof ImageLayer && l.isActive()) {
            il = (ImageLayer) l;
            break;
        }
    }

    vdslayer = (IComplexVectorLayer) layer;

    PlatformConfiguration configuration = SumoPlatform.getApplication().getConfiguration();
    // set the preferences values
    try {
        String colorString = configuration.getAzimuthGeometryColor();
        this.azimuthGeometrycolor = new Color(Integer.parseInt(colorString.equals("") ? Color.ORANGE.getRGB() + "" : colorString));
        this.azimuthGeometrylinewidth = configuration.getAzimuthLineWidth();
    } catch (NumberFormatException e) {
        //Logger.getLogger(GeometricInteractiveVDSLayerModel.class.getName()).log(Level.SEVERE, null, e);
        JOptionPane.showMessageDialog(null, "Wrong format with the preference settings", "Error", JOptionPane.ERROR_MESSAGE);
    }
}
项目:xdman    文件:XDMMainWindow.java   
private void openFile() {
    int row = table.getSelectedRow();
    if (row < 0)
        return;
    DownloadListItem item = list.get(row);
    if (item == null)
        return;
    if (item.state == IXDMConstants.COMPLETE) {
        File file = new File(item.saveto, item.filename);
        if (file.exists()) {
            XDMUtil.open(file);
        } else {
            showMessageBox(getString("FILE_NOT_FOUND"), getString("DEFAULT_TITLE"), JOptionPane.ERROR_MESSAGE);
        }
    } else {
        showMessageBox(getString("DWN_INCOMPLETE"), getString("DEFAULT_TITLE"), JOptionPane.ERROR_MESSAGE);
    }
}
项目:OpenDA    文件:PlotFrame.java   
/** Print using the cross platform dialog.
 *  FIXME: this dialog is slow and is often hidden
 *  behind other windows.  However, it does honor
 *  the user's choice of portrait vs. landscape
 */
protected void _printCrossPlatform() {
    // Build a set of attributes
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(plot);
    if (job.printDialog(aset)) {
        try {
            job.print(aset);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this,
                    "Printing failed:\n" + ex.toString(),
                    "Print Error", JOptionPane.WARNING_MESSAGE);
        }
    }
}
项目:Progetto-N    文件:GuiInformationSale.java   
/**
 * Quando chiudo il programma o il db smette di funzionare
 */
public void imprevisto(){
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent we) {
            int i = JOptionPane.showConfirmDialog(rootPane, "Sei sicuro di voler uscire?");
            if(i==JOptionPane.YES_OPTION){
                try {
                    CreateDb createDb = new CreateDb();
                    createDb.DropSchema();
                    dispose();
                } catch (SQLException ex) {
                    JOptionPane.showMessageDialog(rootPane, "Impossibile raggiungere il Database!");
                }  
            }else
                setDefaultCloseOperation(GuiNome.DO_NOTHING_ON_CLOSE);
        }
    });
}
项目:OpenDiabetes    文件:CommonSwing.java   
public static void errorMessage(Exception exceptionMsg, boolean quiet) {

        /**
         * Display Jpanel Error messages any SQL Errors. Overloads
         * errorMessage(String e)
         */
        Object[] options = { "OK", };

        JOptionPane.showOptionDialog(null, exceptionMsg, messagerHeader,
                                     JOptionPane.DEFAULT_OPTION,
                                     JOptionPane.ERROR_MESSAGE, null,
                                     options, options[0]);

        if (!quiet) {
            exceptionMsg.printStackTrace();
        }

        // DatabaseManagerSwing.StatusMessage(READY_STATUS);
    }
项目:DeutschSim    文件:GUI.java   
private void add_item_about(final JMenu help_menu) {
    JMenuItem item_about = new JMenuItem(new AbstractAction("About"){
        private static final long serialVersionUID = -8311117685045905144L;

        @Override
        public void actionPerformed(ActionEvent arg0) {
            final String text = "DeutschSim by Qwertygid, 2017\n\n" +
                    "https://github.com/QwertygidQ/DeutschSim";

            // TODO add a logo
            JOptionPane.showMessageDialog(frame, text,
                    "About", JOptionPane.INFORMATION_MESSAGE);
        }
    });
    help_menu.add(item_about);
}
项目:Logisim    文件:ProjectLibraryActions.java   
public static void doUnloadLibraries(Project proj) {
    LogisimFile file = proj.getLogisimFile();
    ArrayList<Library> canUnload = new ArrayList<Library>();
    for (Library lib : file.getLibraries()) {
        String message = file.getUnloadLibraryMessage(lib);
        if (message == null)
            canUnload.add(lib);
    }
    if (canUnload.isEmpty()) {
        JOptionPane.showMessageDialog(proj.getFrame(), Strings.get("unloadNoneError"),
                Strings.get("unloadErrorTitle"), JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    LibraryJList list = new LibraryJList(canUnload);
    JScrollPane listPane = new JScrollPane(list);
    int action = JOptionPane.showConfirmDialog(proj.getFrame(), listPane, Strings.get("unloadLibrariesDialogTitle"),
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (action == JOptionPane.OK_OPTION) {
        Library[] libs = list.getSelectedLibraries();
        if (libs != null)
            proj.doAction(LogisimFileActions.unloadLibraries(libs));
    }
}
项目:SkyDocs    文件:ProjectsFrame.java   
/**
 * Saves the projects history.
 */

public final void saveHistory() {
    try {
        final StringBuilder builder = new StringBuilder();
        for(int i = 0; i < projectsModel.size(); i++) {
            builder.append(projectsModel.getElementAt(i) + System.lineSeparator());
        }
        Files.write(builder.toString(), new File(Utils.getParentFolder(), Constants.FILE_GUI_HISTORY), StandardCharsets.UTF_8);
    }
    catch(final Exception ex) {
        ex.printStackTrace(guiPrintStream);
        ex.printStackTrace();
        JOptionPane.showMessageDialog(ProjectsFrame.this, String.format(Constants.GUI_DIALOG_ERROR_MESSAGE, ex.getMessage()), ex.getClass().getName(), JOptionPane.ERROR_MESSAGE);
    }
}
项目:Java-Air-Reservation    文件:ChooseSeat.java   
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    JDesktopPane desktopPane = getDesktopPane();
    int class_ = Integer.parseInt(jComboBox2.getSelectedItem().toString());
    LegClasses lc = new LegClasses(fl.getLeg_no(), class_);
    if (!lc.isExist()) {
        JOptionPane.showMessageDialog(rootPane, "Error: Selected Flight doesnt have that class type");
    } else {
        float amount = lc.getPrice();
        Tickets tk = new Tickets();
        tk.setLeg_no(fl.getLeg_no());
        tk.setClass_(class_);
        tk.setPass_no(cus.getPass_no());
        tk.setSeat_no(Integer.parseInt(jComboBox1.getSelectedItem().toString()));
        if (!tk.save()) {
            JOptionPane.showMessageDialog(rootPane, "Error: Could not reserve ticket");
        } else {
            Payment p = new Payment(cus.getPass_no(), amount);
            desktopPane.add(p);
            p.setVisible(true);
            this.dispose();
        }
    }
}
项目:DigitRecognizer    文件:PredictPanel.java   
private void startPrediction(BufferedImage im)
{
    Thread t = new Thread(() ->
    {
        DRowVector in = DigitManipulator.getAnnInput(im, (x) -> execOnEvtQueue(() -> drawPanel.setImage(x)), 500);
        execOnEvtQueue(() -> drawPanel.setImage(DigitManipulator.vectorToImage(in)));

        NeuralNetwork net = window.getNet();
        if(net.getInputSize() != 784)
        {
            JOptionPane.showMessageDialog(window, "Current Neural Network has wrong input size. Expected:784, Actual:"
                                                  + net.getInputSize(), "Warning", JOptionPane.WARNING_MESSAGE);
            return;
        }
        if(net.getOutputSize() != 10)
        {
            JOptionPane.showMessageDialog(window, "Current Neural Network has wrong output size. Expected:10, Actual:"
                                                  + net.getOutputSize(), "Warning", JOptionPane.WARNING_MESSAGE);
            return;
        }

        DRowVector result = net.feedForward(in);
        execOnEvtQueue(() -> setValues(result.toArray()));
    });
    t.start();
}
项目:Java-Air-Reservation    文件:Login.java   
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

        JDesktopPane desktopPane = getDesktopPane();
        String user = jTextField3.getText();
        String pass = new String(jPasswordField2.getPassword());
        Admin a = new Admin();

        if (a.adminLogin(user, pass)) {
            Adminlogin al = new Adminlogin();
            desktopPane.add(al);
            al.setVisible(true);
            this.dispose();
        } else {
            JOptionPane.showMessageDialog(rootPane, "Error: Username or password incorrect");
        }
    }
项目:xdman    文件:XDMMainWindow.java   
private void refreshLink() {
    int index = table.getSelectedRow();
    if (index < 0) {
        showMessageBox(getString("NONE_SELECTED"), getString("DEFAULT_TITLE"), JOptionPane.ERROR_MESSAGE);
        return;
    }
    DownloadListItem item = list.get(index);
    if (item != null) {
        if (item.state != IXDMConstants.COMPLETE && item.mgr == null) {
            String url = XDMUtil.isNullOrEmpty(item.referer) ? item.url : item.referer;
            url = RefreshLinkDlg.showDialog(this, url);
            if (url != null) {
                item.url = url;
                model.fireTableRowsUpdated(index, index);
                list.downloadStateChanged();
            }
        } else {
            showMessageBox(getString("DWN_ACTIVE_OR_FINISHED"), getString("DEFAULT_TITLE"),
                    JOptionPane.ERROR_MESSAGE);
        }
    }
}
项目:jaer    文件:StereoRecorder.java   
public void doDepthViewer() {
    try {
        System.load(System.getProperty("user.dir") + "\\jars\\openni2\\OpenNI2.dll");

        // initialize OpenNI
        OpenNI.initialize();

        List<DeviceInfo> devicesInfo = OpenNI.enumerateDevices();
        if (devicesInfo.isEmpty()) {
            JOptionPane.showMessageDialog(null, "No device is connected", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }

        Device device = Device.open(devicesInfo.get(0).getUri());

        depthViewerThread = new SimpleDepthCameraViewerApplication(device);
        depthViewerThread.start();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:aulas    文件:Media.java   
public static void main(String[] args) throws IOException {

    String nota1, nota2;
    double media, n1, n2;

    nota1 = JOptionPane.showInputDialog
    ("Digite a primeira nota: ");

    n1 = Double.parseDouble(nota1);
    nota2 = JOptionPane.showInputDialog
    ("Digite a segunda nota: ");

    n2 = Double.parseDouble(nota2);
    media = (n1+n2)/2;

    JOptionPane.showMessageDialog
    (null,"A media aritmetica " + media);
    System.exit(0);
}
项目:VASSAL-src    文件:GameState.java   
protected boolean checkForOldSaveFile(File f) {
  if (f.exists()) {
    // warn user if overwriting a save from an old version
    final AbstractMetaData md = MetaDataFactory.buildMetaData(f);
    if (md != null && md instanceof SaveMetaData) {
      if (Info.hasOldFormat(md.getVassalVersion())) {
        return Dialogs.showConfirmDialog(
          GameModule.getGameModule().getFrame(),
          Resources.getString("Warning.save_will_be_updated_title"),
          Resources.getString("Warning.save_will_be_updated_heading"),
          Resources.getString(
            "Warning.save_will_be_updated_message",
            f.getPath(),
            "3.2"
          ),
            JOptionPane.WARNING_MESSAGE,
          JOptionPane.OK_CANCEL_OPTION) != JOptionPane.CANCEL_OPTION;
      }
    }
  }

  return true;
}
项目:codigo3    文件:Vista.java   
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed
{//GEN-HEADEREND:event_jButton1ActionPerformed
    // TODO add your handling code here:

    ultimoIp= VM.ultimoIP();
    if(VM.getIP() != ultimoIp || VM.pilasVacias())
    {
        VM.interpretarCuadrupla(VM.getCuadrupla(VM.getIP()));
        actualizarVista();
    }
    else
    {
        JOptionPane.showMessageDialog(null, "el programa finalizó", "Mensaje", JOptionPane.ERROR_MESSAGE);
    }

    ip.setText("IP = "+ VM.getIP());

    try
    {
        tablaCuadruplas.setRowSelectionInterval(VM.getIP(), VM.getIP());
    } catch (Exception e)
    {
    }

}
项目:ObsidianSuite    文件:EntitySetupController.java   
public void attemptParent(PartObj parent, PartObj child)
{
    if(parent.getName().equals(child.getName()))
    {
        JOptionPane.showMessageDialog(frame, "Cannot parent a part to itself.", "Parenting issue", JOptionPane.ERROR_MESSAGE);
    } 
    else if (!AnimationParenting.areUnrelated(child, parent) || !AnimationParenting.areUnrelated(parent, child))
    {
        JOptionPane.showMessageDialog(frame, "Parts are already related.", "Parenting issue", JOptionPane.ERROR_MESSAGE);
    }
    else if(child.getParent() != null)
    {
        Object[] options = {"OK", "Remove parenting"};
        int n = JOptionPane.showOptionDialog(frame, child.getDisplayName() + " already has a parent.", "Parenting issue",
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,null,options,options[0]);
        if(n == 1)
        {
            parent(null,child);
        }
    }
    else
        parent(parent, child);
}
项目:Progetto-C    文件:Packer.java   
/**
 * Save the sprite sheet
 */
private void save() {
    int resp = saveChooser.showSaveDialog(this);
    if (resp == JFileChooser.APPROVE_OPTION) {
        File out = saveChooser.getSelectedFile();

        ArrayList list = new ArrayList();
        for (int i=0;i<sprites.size();i++) {
            list.add(sprites.elementAt(i));
        }

        try {
            int b = ((Integer) border.getValue()).intValue();
            pack.packImages(list, twidth, theight, b, out);
        } catch (IOException e) {
            // shouldn't happen 
            e.printStackTrace();
            JOptionPane.showMessageDialog(this, "Failed to write output");
        }
    }
}
项目:sbc-qsystem    文件:FAdmin.java   
private void miAddSectionActionPerformed(
    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miAddSectionActionPerformed
    final String secName = (String) JOptionPane
        .showInputDialog(this, getLocaleMessage("admin.add_section_name.message"),
            getLocaleMessage("admin.section.title"), 3, null, null, "");
    if (secName == null) {
        return;
    }
    if (secName.isEmpty()) {
        JOptionPane.showMessageDialog(this, getLocaleMessage("admin.section_empty.error"),
            getLocaleMessage("admin.section.title"), JOptionPane.ERROR_MESSAGE);
        return;
    }

    if (ServerProps.getInstance().getSection(secName) != null) {
        JOptionPane.showMessageDialog(this, getLocaleMessage("admin.section_dublicate.error"),
            getLocaleMessage("admin.section.title"), JOptionPane.ERROR_MESSAGE);
        return;
    }

    final ServerProps.Section section = ServerProps.getInstance().addSection(secName);
    sectionsList
        .setModel(new DefaultComboBoxModel(ServerProps.getInstance().getSections().toArray()));
    sectionsList.setSelectedValue(section, true);
}
项目:ramus    文件:ChartView.java   
@Override
public JComponent createComponent() {
    ChartDataPlugin plugin = chartDataFramework
            .getChartDataPlugin(chartSource.getChartType());
    try {
        chartPanel = new ChartPanel(plugin.createChart(element));
        chartPanel.setPopupMenu(null);
    } catch (ChartNotSetupedException e) {
        JOptionPane.showMessageDialog(framework.getMainFrame(),
                ChartResourceManager.getString("Error.chartNotSetuped"));
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                close();
            }
        });
        return new JPanel();
    }
    return chartPanel;
}
项目:alevin-svn2    文件:RemoveConstraintDialog.java   
@Override
protected void doAction() {
    if (comboBox.getSelectedIndex() > 0) {
        try {
            // get the selected constraint.
            AbstractConstraint cons = entity.get().get(
                    comboBox.getSelectedIndex() - 1);
            if (!entity.remove(cons)) {
                JOptionPane.showMessageDialog(this,
                        "Cannot remove the last constraint of an entity.",
                        "Error", JOptionPane.ERROR_MESSAGE);
                throw new AssertionError("Removing constraint failed.");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new AssertionError(
                    "An error occured while trying to remove a constraint.");
        }
    }
}
项目:jdk8u-jdk    文件:J2DBench.java   
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;
}
项目:cuttlefish    文件:DBToolbar.java   
private void settingsButtonEvent() {
    String sleepTimeStr = (String)JOptionPane.showInputDialog(networkPanel, "Enter time between updates in milliseconds", "Time between updates", JOptionPane.QUESTION_MESSAGE, null, null, sleepTime);
    if(sleepTimeStr != null) {
        try {
            sleepTime = Long.parseLong(sleepTimeStr);
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(networkPanel, "The value that you enter is not an integer", "Incorrect input", JOptionPane.WARNING_MESSAGE, null);
        }
    }
}
项目:JAddOn    文件:JTreeUtils.java   
private static void editCategory(Component frame, String path, File folder_categories) {
    String input = JOptionPane.showInputDialog(frame, StaticStandard.getLang().getLang("new_category_name", "New category name") + ":", path);
    if (input != null && !input.isEmpty() && !input.equals(path)) {
        File folder_old = getFolderFromCategory(path, folder_categories);
        input = input.replaceAll(File.separator + File.separator, ".");
        File folder = getFolderFromCategory(input, folder_categories);
        folder_old.renameTo(folder);
        StaticStandard.log("Edited category: \"" + path + "\" to \"" + input + "\"");
        folder.mkdirs();
    }
}
项目:MonitorYourLAN    文件:Historic.java   
@Override
public void actionPerformed(ActionEvent e) 
{
    if(e.getSource() == this.updateButton) 
    {
        if(datePicker1.getJFormattedTextField().getText().equals("") == false && datePicker2.getJFormattedTextField().getText().equals("") == false)
        {
            this.displaySPs(thisSP, datePicker1.getJFormattedTextField().getText(), datePicker2.getJFormattedTextField().getText());
        }
        else
        {
            JOptionPane.showMessageDialog(this,"La p�riode s�lectionn�e comporte des erreurs. \n V�rifiez votre saisie.","P�riode non d�finie",JOptionPane.ERROR_MESSAGE);
        }
    }       
}
项目:java-swing-template    文件:Dashboard.java   
public void checkForUpdates() {
    if (new File("updater.exe").exists()) {
        Thread th = new Thread(new Runnable() {
            @Override
            public void run() {
                Utilities.runShellCommand(Updator.COMMAND_UPDATECHECK);
            }
        });
        th.start();
    } else {
        JOptionPane.showMessageDialog(this, "Your software version is not equipped with the automatic update funcationality.\nPlease install the latest software to get updater facility.\nThank you.", "Outdated software", JOptionPane.INFORMATION_MESSAGE);
    }
}
项目:jmt    文件:ModelLoader.java   
/**
 * Overrides default method to provide a warning if saving over an existing file
 */
@Override
public void approveSelection() {
    // Gets the chosen file name
    String name = getSelectedFile().getName();
    String parent = getSelectedFile().getParent();
    if (getDialogType() == OPEN_DIALOG) {
        super.approveSelection();
    }
    if (getDialogType() == SAVE_DIALOG) {
        boolean hasValidExtension = false;
        String[] extensions = defaultSaveFilter.getExtensions();
        for (String e : extensions) {
            if (name.toLowerCase().endsWith(e)) {
                hasValidExtension = true;
                break;
            }
        }
        if (!hasValidExtension) {
            name += extensions[0];
            setSelectedFile(new File(parent, name));
        }
        if (getSelectedFile().exists()) {
            int resultValue = JOptionPane.showConfirmDialog(this, "<html>File <font color=#0000ff>" + name
                    + "</font> already exists in this folder.<br>Do you want to replace it?</html>", "JMT - Warning",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
            if (resultValue == JOptionPane.OK_OPTION) {
                getSelectedFile().delete();
                super.approveSelection();
            }
        } else {
            super.approveSelection();
        }
    }
}
项目:jaer    文件:PanTiltFrame.java   
private void btnHaltActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHaltActionPerformed
    if (panTiltControl == null || panTiltControl.isConnected() == false) {
        JOptionPane.showMessageDialog(null, "Not Connected to Pan-Tilt-Unit", "Not Connected", JOptionPane.OK_CANCEL_OPTION);
    } else {
        panTiltControl.halt();
    }
}
项目:geomapapp    文件:Janus.java   
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();
}
项目:Snake-Ladder    文件:Main.java   
public void Paint(int x, int y){
    //System.out.println("Paint from: "+x+" to "+y);
    new Thread() {
        @Override
        public void run() {
            try {
                //btnDice.setEnabled(false);
                //btnDice.setVisible(false);
                Thread.sleep(500);
                for(int i=x; i<y; i++){
                    //System.out.println("Paint Player after: "+p);
                    RemoveImage(i);
                    Thread.sleep(50);
                    SetImage(i+1,player);
                    Thread.sleep(500);
                }
                //btnDice.setVisible(true);
                //btnDice.setEnabled(true);
            } catch (InterruptedException ex) {
                Thread.currentThread().interrupt();
                JOptionPane.showMessageDialog(null, "Paint timer error!");
            }

        }
    }.start();


   ActionListener taskPerformer = new ActionListener() {
        public void actionPerformed(ActionEvent evt) {


        }
    };
    javax.swing.Timer t = new javax.swing.Timer(1000, taskPerformer);
    t.setRepeats(false);
    t.start();
}
项目:litiengine    文件:Program.java   
private static boolean exit() {
  String resourceFile = EditorScreen.instance().getCurrentResourceFile() != null ? EditorScreen.instance().getCurrentResourceFile() : "";
  int n = JOptionPane.showConfirmDialog(
      null,
      Resources.get("hud_saveProjectMessage") + "\n" + resourceFile,
      Resources.get("hud_saveProject"),
      JOptionPane.YES_NO_CANCEL_OPTION);

  if (n == JOptionPane.YES_OPTION) {
    EditorScreen.instance().save(false);
  }

  return n != JOptionPane.CANCEL_OPTION;
}