Example usage for javax.swing JOptionPane YES_OPTION

List of usage examples for javax.swing JOptionPane YES_OPTION

Introduction

In this page you can find the example usage for javax.swing JOptionPane YES_OPTION.

Prototype

int YES_OPTION

To view the source code for javax.swing JOptionPane YES_OPTION.

Click Source Link

Document

Return value from class method if YES is chosen.

Usage

From source file:com.raddle.tools.MergeMain.java

private void initGUI() {
    try {//w  w w. j av  a 2s.co m
        {
            this.setBounds(0, 0, 1050, 600);
            getContentPane().setLayout(null);
            this.setTitle("\u5c5e\u6027\u6587\u4ef6\u6bd4\u8f83");
            {
                sourceTxt = new JTextField();
                getContentPane().add(sourceTxt);
                sourceTxt.setBounds(12, 12, 373, 22);
            }
            {
                sourceBtn = new JButton();
                getContentPane().add(sourceBtn);
                sourceBtn.setText("\u6253\u5f00");
                sourceBtn.setBounds(406, 12, 74, 22);
                sourceBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        JFileChooser fileChooser = new JFileChooser(); // 
                        fileChooser.addChoosableFileFilter(
                                new FileNameExtensionFilter("", "properties"));
                        File curFile = new File(sourceTxt.getText());
                        if (curFile.exists()) {
                            fileChooser.setCurrentDirectory(curFile.getParentFile());
                        }
                        int result = fileChooser.showOpenDialog(MergeMain.this);
                        if (result == JFileChooser.APPROVE_OPTION) {
                            File selected = fileChooser.getSelectedFile();
                            source = new PropertyHolder(selected, "utf-8");
                            sourceTxt.setText(selected.getAbsolutePath());
                            properties.setProperty("left.file", selected.getAbsolutePath());
                            savePropMergeFile();
                            compare();
                        }
                    }
                });
            }
            {
                targetTxt = new JTextField();
                getContentPane().add(targetTxt);
                targetTxt.setBounds(496, 12, 419, 22);
            }
            {
                targetBtn = new JButton();
                getContentPane().add(targetBtn);
                targetBtn.setText("\u6253\u5f00");
                targetBtn.setBounds(935, 12, 81, 22);
                targetBtn.setSize(74, 22);
                targetBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        JFileChooser fileChooser = new JFileChooser(); // 
                        fileChooser.addChoosableFileFilter(
                                new FileNameExtensionFilter("", "properties"));
                        File curFile = new File(targetTxt.getText());
                        if (curFile.exists()) {
                            fileChooser.setCurrentDirectory(curFile.getParentFile());
                        }
                        int result = fileChooser.showOpenDialog(MergeMain.this);
                        if (result == JFileChooser.APPROVE_OPTION) {
                            File selected = fileChooser.getSelectedFile();
                            target = new PropertyHolder(selected, "utf-8");
                            targetTxt.setText(selected.getAbsolutePath());
                            properties.setProperty("right.file", selected.getAbsolutePath());
                            savePropMergeFile();
                            compare();
                        }
                    }
                });
            }
            {
                jScrollPane1 = new JScrollPane();
                getContentPane().add(jScrollPane1);
                jScrollPane1.setBounds(12, 127, 373, 413);
                {
                    ListModel sourceListModel = new DefaultComboBoxModel(new String[] {});
                    sourceList = new JList();
                    jScrollPane1.setViewportView(sourceList);
                    sourceList.setAutoscrolls(true);
                    sourceList.setModel(sourceListModel);
                    sourceList.addKeyListener(new KeyAdapter() {
                        @Override
                        public void keyPressed(KeyEvent evt) {
                            if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
                                PropertyLine v = (PropertyLine) sourceList.getSelectedValue();
                                if (v != null) {
                                    int ret = JOptionPane.showConfirmDialog(MergeMain.this,
                                            "?" + v.getKey() + "?");
                                    if (ret == JOptionPane.YES_OPTION) {
                                        v.setState(LineState.deleted);
                                        compare();
                                        sourceList.setSelectedValue(v, true);
                                    }
                                }
                            }
                        }
                    });
                    sourceList.addMouseListener(new MouseAdapter() {
                        @Override
                        public void mouseClicked(MouseEvent evt) {
                            if (evt.getClickCount() == 2) {
                                Object v = sourceList.getSelectedValue();
                                updatePropertyLine((PropertyLine) v);
                                sourceList.setSelectedValue(v, true);
                            }
                        }
                    });
                    sourceList.addListSelectionListener(new ListSelectionListener() {

                        @Override
                        public void valueChanged(ListSelectionEvent evt) {
                            if (sourceList.getSelectedValue() != null) {
                                PropertyLine pl = (PropertyLine) sourceList.getSelectedValue();
                                if (target != null) {
                                    PropertyLine p = target.getLine(pl.getKey());
                                    if (p != null) {
                                        TextDiffResult rt = TextdiffUtil.getDifferResult(p.toString(),
                                                pl.toString());
                                        diffResultPane.setText("" + rt.getTargetHtml() + "<br/>?"
                                                + rt.getSrcHtml());
                                        selectLine(targetList, p);
                                        return;
                                    }
                                }
                                TextDiffResult rt = TextdiffUtil.getDifferResult("", pl.toString());
                                diffResultPane.setText(
                                        "" + rt.getTargetHtml() + "<br/>?" + rt.getSrcHtml());

                            }
                        }
                    });
                }
            }
            {
                jScrollPane2 = new JScrollPane();
                getContentPane().add(jScrollPane2);
                jScrollPane2.setBounds(496, 127, 419, 413);
                {
                    ListModel targetListModel = new DefaultComboBoxModel(new String[] {});
                    targetList = new JList();
                    jScrollPane2.setViewportView(targetList);
                    targetList.setAutoscrolls(true);
                    targetList.setModel(targetListModel);
                    targetList.addKeyListener(new KeyAdapter() {
                        @Override
                        public void keyPressed(KeyEvent evt) {
                            if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
                                PropertyLine v = (PropertyLine) targetList.getSelectedValue();
                                if (v != null) {
                                    int ret = JOptionPane.showConfirmDialog(MergeMain.this,
                                            "?" + v.getKey() + "?");
                                    if (ret == JOptionPane.YES_OPTION) {
                                        v.setState(LineState.deleted);
                                        compare();
                                        targetList.setSelectedValue(v, true);
                                    }
                                }
                            }
                        }
                    });
                    targetList.addMouseListener(new MouseAdapter() {
                        @Override
                        public void mouseClicked(MouseEvent evt) {
                            if (evt.getClickCount() == 2) {
                                Object v = targetList.getSelectedValue();
                                updatePropertyLine((PropertyLine) v);
                                targetList.setSelectedValue(v, true);
                            }
                        }
                    });
                    targetList.addListSelectionListener(new ListSelectionListener() {

                        @Override
                        public void valueChanged(ListSelectionEvent evt) {
                            if (targetList.getSelectedValue() != null) {
                                PropertyLine pl = (PropertyLine) targetList.getSelectedValue();
                                if (source != null) {
                                    PropertyLine s = source.getLine(pl.getKey());
                                    if (s != null) {
                                        TextDiffResult rt = TextdiffUtil.getDifferResult(pl.toString(),
                                                s.toString());
                                        diffResultPane.setText("" + rt.getTargetHtml() + "<br/>?"
                                                + rt.getSrcHtml());
                                        selectLine(sourceList, s);
                                        return;
                                    }
                                }
                                TextDiffResult rt = TextdiffUtil.getDifferResult(pl.toString(), "");
                                diffResultPane.setText(
                                        "" + rt.getTargetHtml() + "<br/>?" + rt.getSrcHtml());
                            }
                        }
                    });
                }
            }
            {
                sourceSaveBtn = new JButton();
                getContentPane().add(sourceSaveBtn);
                sourceSaveBtn.setText("\u4fdd\u5b58");
                sourceSaveBtn.setBounds(406, 45, 74, 22);
                sourceSaveBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        int result = JOptionPane.showConfirmDialog(MergeMain.this,
                                "???\n"
                                        + source.getPropertyFile().getAbsolutePath());
                        if (result == JOptionPane.YES_OPTION) {
                            source.saveFile();
                            JOptionPane.showMessageDialog(MergeMain.this, "??");
                            clearState(source);
                            compare();
                        }
                    }
                });
            }
            {
                targetSaveBtn = new JButton();
                getContentPane().add(targetSaveBtn);
                targetSaveBtn.setText("\u4fdd\u5b58");
                targetSaveBtn.setBounds(935, 45, 81, 22);
                targetSaveBtn.setSize(74, 22);
                targetSaveBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        int result = JOptionPane.showConfirmDialog(MergeMain.this,
                                "????\n"
                                        + target.getPropertyFile().getAbsolutePath());
                        if (result == JOptionPane.YES_OPTION) {
                            target.saveFile();
                            JOptionPane.showMessageDialog(MergeMain.this, "??");
                            clearState(target);
                            compare();
                        }
                    }
                });
            }
            {
                toTargetBtn = new JButton();
                getContentPane().add(toTargetBtn);
                toTargetBtn.setText("->");
                toTargetBtn.setBounds(406, 221, 74, 22);
                toTargetBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        Object[] oo = sourceList.getSelectedValues();
                        for (Object selected : oo) {
                            PropertyLine s = (PropertyLine) selected;
                            if (s != null && target != null) {
                                PropertyLine t = target.getLine(s.getKey());
                                if (t == null) {
                                    PropertyLine n = s.clone();
                                    n.setState(LineState.added);
                                    target.addPropertyLineAtSuitedPosition(n);
                                } else if (!t.getValue().equals(s.getValue())) {
                                    t.setState(LineState.updated);
                                    t.setValue(s.getValue());
                                } else if (t.getState() == LineState.deleted) {
                                    if (t.getValue().equals(t.getOriginalValue())) {
                                        t.setState(LineState.original);
                                    } else {
                                        t.setState(LineState.updated);
                                    }
                                }
                                compare();
                            }
                        }
                    }
                });
            }
            {
                toSourceBtn = new JButton();
                getContentPane().add(toSourceBtn);
                toSourceBtn.setText("<-");
                toSourceBtn.setBounds(406, 255, 74, 22);
                toSourceBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        Object[] oo = targetList.getSelectedValues();
                        for (Object selected : oo) {
                            PropertyLine t = (PropertyLine) selected;
                            if (t != null && source != null) {
                                PropertyLine s = source.getLine(t.getKey());
                                if (s == null) {
                                    PropertyLine n = t.clone();
                                    n.setState(LineState.added);
                                    source.addPropertyLineAtSuitedPosition(n);
                                } else if (!s.getValue().equals(t.getValue())) {
                                    s.setState(LineState.updated);
                                    s.setValue(t.getValue());
                                } else if (s.getState() == LineState.deleted) {
                                    if (s.getValue().equals(s.getOriginalValue())) {
                                        s.setState(LineState.original);
                                    } else {
                                        s.setState(LineState.updated);
                                    }
                                }
                                compare();
                            }
                        }
                    }
                });
            }
            {
                jScrollPane3 = new JScrollPane();
                getContentPane().add(jScrollPane3);
                jScrollPane3.setBounds(12, 73, 903, 42);
                {
                    diffResultPane = new JTextPane();
                    jScrollPane3.setViewportView(diffResultPane);
                    diffResultPane.setBounds(12, 439, 903, 63);
                    diffResultPane.setContentType("text/html");
                    diffResultPane.setPreferredSize(new java.awt.Dimension(901, 42));
                }
            }
            {
                compareBtn = new JButton();
                getContentPane().add(compareBtn);
                compareBtn.setText("\u6bd4\u8f83");
                compareBtn.setBounds(406, 139, 74, 22);
                compareBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        compare();
                    }
                });
            }
            {
                sourceReloadBtn = new JButton();
                getContentPane().add(sourceReloadBtn);
                sourceReloadBtn.setText("\u91cd\u65b0\u8f7d\u5165");
                sourceReloadBtn.setBounds(12, 40, 64, 29);
                sourceReloadBtn.setSize(90, 22);
                sourceReloadBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (sourceTxt.getText().length() > 0) {
                            File curFile = new File(sourceTxt.getText().trim());
                            if (curFile.exists()) {
                                source = new PropertyHolder(curFile, "utf-8");
                                sourceTxt.setText(curFile.getAbsolutePath());
                                properties.setProperty("left.file", curFile.getAbsolutePath());
                                savePropMergeFile();
                                compare();
                            } else {
                                JOptionPane.showMessageDialog(MergeMain.this,
                                        "" + curFile.getAbsolutePath() + "?");
                            }
                        }
                    }
                });
            }
            {
                targetReloadBtn = new JButton();
                getContentPane().add(targetReloadBtn);
                targetReloadBtn.setText("\u91cd\u65b0\u8f7d\u5165");
                targetReloadBtn.setBounds(839, 45, 90, 22);
                targetReloadBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (targetTxt.getText().length() > 0) {
                            File curFile = new File(targetTxt.getText().trim());
                            if (curFile.exists()) {
                                target = new PropertyHolder(curFile, "utf-8");
                                targetTxt.setText(curFile.getAbsolutePath());
                                properties.setProperty("right.file", curFile.getAbsolutePath());
                                savePropMergeFile();
                                compare();
                            } else {
                                JOptionPane.showMessageDialog(MergeMain.this,
                                        "" + curFile.getAbsolutePath() + "?");
                            }
                        }
                    }
                });
            }
            {
                helpBtn = new JButton();
                getContentPane().add(helpBtn);
                helpBtn.setText("\u5e2e\u52a9");
                helpBtn.setBounds(405, 338, 38, 29);
                helpBtn.setSize(74, 22);
                helpBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        StringBuilder sb = new StringBuilder();
                        sb.append("?").append("\n");
                        sb.append("del").append("\n");
                        sb.append("??").append("\n");
                        sb.append(": /.prop-merge/prop-merge.properties").append("\n");
                        JOptionPane.showMessageDialog(MergeMain.this, sb.toString());
                    }
                });
            }
            {
                sourceEditBtn = new JButton();
                getContentPane().add(sourceEditBtn);
                sourceEditBtn.setText("\u7f16\u8f91\u6587\u4ef6");
                sourceEditBtn.setBounds(108, 40, 90, 22);
                sourceEditBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (sourceTxt.getText().length() > 0) {
                            File curFile = new File(sourceTxt.getText());
                            editFile(curFile);
                        }
                    }
                });
            }
            {
                targetEditBtn = new JButton();
                getContentPane().add(targetEditBtn);
                targetEditBtn.setText("\u7f16\u8f91\u6587\u4ef6");
                targetEditBtn.setBounds(743, 45, 90, 22);
                targetEditBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (targetTxt.getText().length() > 0) {
                            File curFile = new File(targetTxt.getText());
                            editFile(curFile);
                        }
                    }
                });
            }
        }
        pack();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:net.landora.video.manager.ManagerFrame.java

public void exit() {
    int reply = JOptionPane.showConfirmDialog(this, "Are you sure you wish to quit?", "Exit",
            JOptionPane.YES_NO_OPTION);
    if (reply == JOptionPane.YES_OPTION) {
        System.exit(0);/*from  ww w  .j  ava  2  s  .  com*/
    }
}

From source file:gdt.jgui.base.JPropertyPanel.java

/**
 * Response on menu action/*from   w w  w  . j a  va2s  . c o  m*/
 * @param console main console
 * @param locator$ the locator string.
 */
@Override
public void response(JMainConsole console, String locator$) {
    try {
        //System.out.println("PropertyPanel:response:locator="+locator$);
        Properties locator = Locator.toProperties(locator$);
        String action$ = locator.getProperty(JRequester.REQUESTER_ACTION);
        String entihome$ = locator.getProperty(Entigrator.ENTIHOME);
        Entigrator entigrator = console.getEntigrator(entihome$);
        if (ACTION_ADD_PROPERTY.equals(action$)) {
            String text$ = locator.getProperty(JTextEditor.TEXT);
            //   System.out.println("PropertyPanel:response:property="+text$);
            if (text$ != null)
                entigrator.indx_addPropertyName(text$);
            JDesignPanel dp = new JDesignPanel();
            String dpLocator$ = dp.getLocator();
            dpLocator$ = Locator.append(dpLocator$, Entigrator.ENTIHOME, entihome$);
            dpLocator$ = Locator.append(dpLocator$, JDesignPanel.PROPERTY_NAME, text$);
            JConsoleHandler.execute(console, dpLocator$);
            return;
        }
        if (ACTION_EDIT_PROPERTY.equals(action$)) {
            String text$ = locator.getProperty(JTextEditor.TEXT);
            String propertyName$ = locator.getProperty(JDesignPanel.PROPERTY_NAME);
            //   System.out.println("PropertyPanel:response:set  property name ="+propertyName$+" new="+text$);
            if (text$ != null)
                entigrator.prp_editPropertyName(propertyName$, text$);

            JDesignPanel dp = new JDesignPanel();
            String dpLocator$ = dp.getLocator();
            dpLocator$ = Locator.append(dpLocator$, Entigrator.ENTIHOME, entihome$);
            dpLocator$ = Locator.append(dpLocator$, JDesignPanel.PROPERTY_NAME, text$);
            JConsoleHandler.execute(console, dpLocator$);
            return;
        }
        if (ACTION_CLEAR_PROPERTIES.equals(action$)) {
            //System.out.println("PropertyPanel:response:action="+action$);
            int response = JOptionPane.showConfirmDialog(console.getContentPanel(),
                    "Delete unused properties ?", "Confirm", JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.YES_OPTION) {
                entigrator.prp_deleteWrongEntries();
                JDesignPanel dp = new JDesignPanel();
                String dpLocator$ = dp.getLocator();
                dpLocator$ = Locator.append(dpLocator$, Entigrator.ENTIHOME, entihome$);
                JConsoleHandler.execute(console, dpLocator$);
                return;
            }
        }
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
}

From source file:com.biosis.sgb.vistas.dialogos.PersonaCRUD.java

private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
    // TODO add your handling code here:
    this.accion = ELIMINAR;
    if (JOptionPane.showConfirmDialog(this, "Est seguro que desea eliminar esta persona?",
            "Mensaje del sistema", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
        if (this.personaControlador.accion(accion)) {
            FormularioUtil.mensajeExito(this, accion);
            this.persona = null;
            this.dispose();
        }//from  w  w w  .  j  a v a 2 s  .c o  m
    }
}

From source file:condorclient.MainFXMLController.java

@FXML

void deleteButtonFired(ActionEvent event) {
    int delNo = 0;

    int n = JOptionPane.showConfirmDialog(null, "??", "",
            JOptionPane.YES_NO_OPTION);
    if (n == JOptionPane.YES_OPTION) {

        URL url = null;//from  www.  j  a v a2 s .  c  o  m
        XMLHandler handler = new XMLHandler();
        String scheddStr = handler.getURL("schedd");
        try {
            url = new URL(scheddStr);
            // url = new URL("http://localhost:9628");
        } catch (MalformedURLException e3) {
            // TODO Auto-generated catch block
            e3.printStackTrace();
        }
        Schedd schedd = null;

        try {
            schedd = new Schedd(url);
        } catch (ServiceException ex) {
            Logger.getLogger(CondorClient.class.getName()).log(Level.SEVERE, null, ex);
        }

        //ClassAdStructAttr[]
        ClassAd ad = null;//birdbath.ClassAd;
        ClassAdStructAttr[][] classAdArray = null;

        int cluster = 0;

        int job = 0;
        Transaction xact = schedd.createTransaction();
        try {
            xact.begin(30);

        } catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        final List<?> selectedNodeList = new ArrayList<>(table.getSelectionModel().getSelectedItems());
        String taskStatus = "";
        for (Object o : selectedNodeList) {
            if (o instanceof ObservableDisplayedClassAd) {
                delNo = Integer.parseInt(((ObservableDisplayedClassAd) o).getClusterId());
                taskStatus = ((ObservableDisplayedClassAd) o).getJobStatus();
                if (taskStatus.equals("")) {
                    JOptionPane.showMessageDialog(null, "?");
                    return;
                }
                String findreq = "owner==\"" + condoruser + "\"&&ClusterId==" + delNo;
                try {
                    classAdArray = schedd.getJobAds(findreq);
                } catch (RemoteException ex) {
                    Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex);
                }
                for (ClassAdStructAttr[] x : classAdArray) {
                    ad = new ClassAd(x);
                    job = Integer.parseInt(ad.get("ProcId"));
                    try {
                        xact.closeSpool(delNo, job);

                        // System.out.print("ts.getClusterId():" + showClusterId + "\n");
                    } catch (RemoteException ex) {
                        Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                try {
                    xact.removeCluster(delNo, "");
                } catch (RemoteException ex) {
                    Logger.getLogger(MainFXMLController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        //end

        try {
            xact.commit();
        } catch (RemoteException e) {

            e.printStackTrace();
        }
        //??
        //            XMLHandler handler = new XMLHandler();
        int delNo1[] = new int[1];//
        delNo1[0] = delNo;
        handler.removeJobs(delNo1, 1);

    } else if (n == JOptionPane.NO_OPTION) {
        System.out.println("qu xiao");

    }

}

From source file:gdt.jgui.entity.query.JQueryPanel.java

/**
 * Get the context menu./*from w  w w .ja  va2 s .  c o  m*/
 * @return the context menu.
 */
@Override
public JMenu getContextMenu() {
    menu = new JMenu("Context");
    menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            menu.removeAll();
            //            System.out.println("BookmarksEditor:getConextMenu:menu selected");
            JMenuItem selectItem = new JMenuItem("Select");
            selectItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    showHeader();
                    showContent();
                }
            });
            menu.add(selectItem);
            JMenuItem clearHeader = new JMenuItem("Clear all");
            clearHeader.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    clearHeader();
                    showHeader();
                    showContent();
                }
            });
            menu.add(clearHeader);
            Entigrator entigrator = console.getEntigrator(entihome$);
            Sack query = entigrator.getEntityAtKey(entityKey$);
            if (query.getElementItem("parameter", "noreset") == null) {
                JMenuItem resetItem = new JMenuItem("Reset");
                resetItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        int response = JOptionPane.showConfirmDialog(console.getContentPanel(),
                                "Reset source to default ?", "Confirm", JOptionPane.YES_NO_OPTION,
                                JOptionPane.QUESTION_MESSAGE);
                        if (response == JOptionPane.YES_OPTION)
                            reset();
                    }
                });
                menu.add(resetItem);
            }
            JMenuItem folderItem = new JMenuItem("Open folder");
            folderItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        File file = new File(entihome$ + "/" + entityKey$);
                        Desktop.getDesktop().open(file);
                    } catch (Exception ee) {
                        Logger.getLogger(getClass().getName()).info(ee.toString());
                    }
                }
            });
            menu.add(folderItem);

            menu.addSeparator();
            JMenuItem addHeader = new JMenuItem("Add column");
            addHeader.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    addHeader();
                }
            });
            menu.add(addHeader);
            JMenuItem removeColumn = new JMenuItem("Remove column ");
            removeColumn.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    removeColumn();
                }
            });
            menu.add(removeColumn);
            ListSelectionModel lsm = table.getSelectionModel();
            if (!lsm.isSelectionEmpty()) {
                JMenuItem excludeRows = new JMenuItem("Exclude rows ");
                excludeRows.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        Entigrator entigrator = console.getEntigrator(entihome$);
                        Sack query = entigrator.getEntityAtKey(entityKey$);
                        if (!query.existsElement("exclude"))
                            query.createElement("exclude");
                        //else
                        //   query.clearElement("exclude");
                        ListSelectionModel lsm = table.getSelectionModel();
                        int minIndex = lsm.getMinSelectionIndex();
                        int maxIndex = lsm.getMaxSelectionIndex();
                        for (int i = minIndex; i <= maxIndex; i++) {
                            if (lsm.isSelectedIndex(i)) {
                                System.out.println("JQueryPanel:exclude rows:label=" + table.getValueAt(i, 1));
                                query.putElementItem("exclude",
                                        new Core(null, (String) table.getValueAt(i, 1), null));
                            }
                        }
                        entigrator.save(query);
                        showHeader();
                        showContent();
                    }
                });
                menu.add(excludeRows);
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    return menu;
}

From source file:charitypledge.Pledge.java

private void ExitButtonActionPerformed(java.awt.event.ActionEvent evt) {
    JFrame frame = new JFrame();
    int confirm = JOptionPane.showOptionDialog(frame, "Are You Sure to Close this Application?",
            "Exit Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    if (confirm == JOptionPane.YES_OPTION) {
        System.exit(0);//from w  w  w  .j a  v a  2s.  c om
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchChurchFrame.java

private void deleteSelection() {
    int[] rows = jChurchTable.getSelectedRows();
    if (rows.length == 0) {
        return;//from w w  w  . jav a2s  .  c om
    }
    String message = ((rows.length == 1) ? "Kirchendorf " : (rows.length + " Kirchendrfer "))
            + "wirklich lschen?";
    if (JOptionPaneHelper.showQuestionConfirmBox(this, message, "Lschen", "Nein",
            "Ja") == JOptionPane.YES_OPTION) {
        //get markers to remove
        List<Village> toRemove = new LinkedList<>();
        jChurchTable.invalidate();
        for (int i = rows.length - 1; i >= 0; i--) {
            int row = jChurchTable.convertRowIndexToModel(rows[i]);
            int col = jChurchTable.convertColumnIndexToModel(1);
            Village v = ((KnownVillage) jChurchTable.getModel().getValueAt(row, col)).getVillage();
            toRemove.add(v);
        }
        jChurchTable.revalidate();
        //remove all selected markers and update the view once
        KnownVillageManager.getSingleton().removeChurches(toRemove.toArray(new Village[] {}));
        showSuccess(toRemove.size() + ((toRemove.size() == 1) ? " Kirche gelscht" : " Kirchen gelscht"));
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchReTimerFrame.java

private void copyAttacksToClipboardAsBBCode() {
    jideRetimeTabbedPane.setSelectedIndex(1);
    try {/*from w ww . j  a va2  s . c o m*/
        List<Attack> attacks = getSelectedAttacks();
        if (attacks.isEmpty()) {
            showInfo("Keine Angriffe ausgewhlt");
            return;
        }
        boolean extended = (JOptionPaneHelper.showQuestionConfirmBox(this,
                "Erweiterte BB-Codes verwenden (nur fr Forum und Notizen geeignet)?", "Erweiterter BB-Code",
                "Nein", "Ja") == JOptionPane.YES_OPTION);

        StringBuilder buffer = new StringBuilder();
        if (extended) {
            buffer.append("[u][size=12]Angriffsplan[/size][/u]\n\n");
        } else {
            buffer.append("[u]Angriffsplan[/u]\n\n");
        }

        buffer.append(new AttackListFormatter().formatElements(attacks, extended));

        if (extended) {
            buffer.append("\n[size=8]Erstellt am ");
            buffer.append(
                    new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime()));
            buffer.append(" mit DS Workbench ");
            buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "[/size]\n");
        } else {
            buffer.append("\nErstellt am ");
            buffer.append(
                    new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime()));
            buffer.append(" mit DS Workbench ");
            buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "\n");
        }

        String b = buffer.toString();
        StringTokenizer t = new StringTokenizer(b, "[");
        int cnt = t.countTokens();
        if (cnt > 1000) {
            if (JOptionPaneHelper.showQuestionConfirmBox(this,
                    "Die ausgewhlten Angriffe bentigen mehr als 1000 BB-Codes\n"
                            + "und knnen daher im Spiel (Forum/IGM/Notizen) nicht auf einmal dargestellt werden.\nTrotzdem exportieren?",
                    "Zu viele BB-Codes", "Nein", "Ja") == JOptionPane.NO_OPTION) {
                return;
            }
        }

        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(b), null);
        String result = "Daten in Zwischenablage kopiert.";
        showSuccess(result);
    } catch (Exception e) {
        logger.error("Failed to copy data to clipboard", e);
        String result = "Fehler beim Kopieren in die Zwischenablage.";
        showError(result);
    }
}

From source file:marytts.tools.voiceimport.DatabaseImportMain.java

protected void closeGUI() {
    // This doesn't work because Java cannot close the X11 connection, see
    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4420885
    int answer = JOptionPane.showOptionDialog(this,
            "Do you want to close this GUI?\n\n"
                    + "The components that are currently running will continue to run,\n"
                    + "but you will not be able to save settings or select/deselect\n" + "components to run.\n"
                    + "This may be useful when running this tool using 'nohup' on a server\n"
                    + "because it allows you to log off without stopping the process.",
            "Really close GUI?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    if (answer == JOptionPane.YES_OPTION) {
        this.setVisible(false);
        this.dispose();
    }/*from www  . j a  va  2  s  .c om*/
}