Example usage for java.awt.event MouseEvent BUTTON3

List of usage examples for java.awt.event MouseEvent BUTTON3

Introduction

In this page you can find the example usage for java.awt.event MouseEvent BUTTON3.

Prototype

int BUTTON3

To view the source code for java.awt.event MouseEvent BUTTON3.

Click Source Link

Document

Indicates mouse button #3; used by #getButton .

Usage

From source file:edmondskarp.Gui.EdmondsKarpGui.java

private void myPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_myPanelMouseClicked
    if (evt.getButton() == MouseEvent.BUTTON1) {

        if (MODE == ERASE) {
            eraseShape(evt.getPoint());// w ww  .  j  a va2  s. co m
        } else if (MODE == DRAW) {

            if (isSecond) {
                Circle circ = getSelectedCircle(evt.getPoint());
                if (circ != null && circ != shapeTmp) {
                    addArrow(circ);
                    shapeTmp.setSelect(false);
                    isSecond = false;
                    update();
                    return;
                }
            } else {
                Circle circ = getSelectedCircle(evt.getPoint());
                if (circ != null) {
                    shapeTmp = circ;
                    shapeTmp.setSelect(true);
                    isSecond = true;
                    update();
                    return;
                }

            }

            if (getSelectedCircle(evt.getPoint()) == null && !isSecond) {
                addCircle(evt.getPoint());
            } else {
                isSecond = false;
                shapeTmp.setSelect(false);
                update();
            }
        }
    } else if (evt.getButton() == MouseEvent.BUTTON3) {
        if (getSelectedCircle(evt.getPoint()) != null) {
            pointTmp.setLocation(evt.getPoint().getX(), evt.getPoint().getY());
            jPopupMenu1.show(myPanel, evt.getX(), evt.getY());
        } else if (getSelectedArrow(evt.getPoint()) != null) {
            pointTmp.setLocation(evt.getPoint().getX(), evt.getPoint().getY());
            jPopupMenu2.show(myPanel, evt.getX(), evt.getY());
        }
    }
}

From source file:NewGUI.Statistics.java

private void tbListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbListMouseClicked
    // TODO add your handling code here:

    if (evt.getButton() == MouseEvent.BUTTON3) {
        Point point = evt.getLocationOnScreen();
        popupTable.setLocation(point);/*from   w w  w .ja v a  2 s.c om*/
        popupTable.setVisible(true);
    }
}

From source file:corelyzer.ui.CorelyzerGLCanvas.java

public void mousePressed(final MouseEvent e) {
    prePos = e.getPoint();/*w  ww  .ja v a2 s  .  c o m*/
    float sp[] = { 0.0f, 0.0f };
    this.convertMousePointToSceneSpace(prePos, scenePos);

    PAN_MODE = 0;
    ZOOM_MODE = 0;
    MANIPULATE_MODE = 0;

    // For mouse right-click or Ctrl-Left-Click
    if (e.isPopupTrigger()) {
        this.handleRightMouseClick(e);

        return;
    }

    switch (e.getButton()) {
    case MouseEvent.BUTTON1:

        if (canvasMode == CorelyzerApp.APP_MEASURE_MODE) {
            return;
        } else if (canvasMode == CorelyzerApp.APP_MARKER_MODE) {

            // the first check up: focused marker manipulation
            if (SceneGraph.focusedMarker > -1) {
                if (SceneGraph.hitMarker(canvasId, scenePos[0], scenePos[1])) {
                    MANIPULATE_MODE = 1;

                    /*
                     * System.out.println(
                     * "---- Left button pressed down at: " + prePos.x +
                     * ", " + prePos.y); System.out.println(
                     * "Converted to Scene Space: " + scenePos[0] + ", "
                     * + sp[1]);
                     * System.out.println("Marker manipulator hit!");
                     */

                    prescenePos[0] = scenePos[0];
                    prescenePos[1] = scenePos[1];

                    return;
                }
            }
        } else if (canvasMode == CorelyzerApp.APP_CLAST_MODE || canvasMode == CorelyzerApp.APP_CUT_MODE)

        {
            determineSelectedSceneComponents(scenePos, e);

            if (selectedTrackSection != -1) {
                if (!SceneGraph.getDepthOrientation()) {
                    float t = scenePos[0];
                    scenePos[0] = scenePos[1];
                    scenePos[1] = -t;
                }

                SceneGraph.addClastPoint1(scenePos[0], scenePos[1]);
                this.convertScenePointToAbsolute(scenePos, sp);

                CorelyzerApp.getApp().getToolFrame().setClastUpperLeft(sp);
            }

            PAN_MODE = 0;
            return;
        }

        PAN_MODE = 1;

        // System.out.println("---- Left button pressed down at: " +
        // prePos.x + ", " + prePos.y);
        // System.out.println("Converted to Scene Space: " +
        // scenePos[0] + ", " + sp[1]);

        determineSelectedSceneComponents(scenePos, e);

        break;
    case MouseEvent.BUTTON2:
        // System.out.println("MOUSE BUTTON 2!!!???");
        break;
    case MouseEvent.BUTTON3:
        // System.out.println("---- Right button clicked at: " +
        // prePos.x + ", " + prePos.y);
        // System.out.println("Converted to Scene Space: " +
        // scenePos[0] + ", " + sp[1]);
        this.handleRightMouseClick(e);
        break;
    default:
        // more reliable than BUTTON3 (ctrl-click)
        if (e.isPopupTrigger()) {
            this.handleRightMouseClick(e);
        }
    }
}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

@Override
public void mousePressed(final MouseEvent e) {
    final boolean ctrlPressed = (e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0;
    if (this.application == null) {
        if (!ctrlPressed && e.isPopupTrigger()) {
            final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint());
            onPopup(e.getPoint(), hexNumber);
        } else {/*from w w w  .j  a  v  a2s.  c  o m*/
            switch (e.getButton()) {
            case MouseEvent.BUTTON1: {
                if (selectedToolType != null && this.selectedLayer != null) {
                    addedUndoStep(new HexFieldLayer[] { this.selectedLayer });
                    final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint());
                    useCurrentToolAtPosition(hexNumber);
                }
            }
                break;
            case MouseEvent.BUTTON3: {
                if (ctrlPressed) {
                    this.dragging = true;
                    this.hexMapPanelDesktop.initDrag(e.getPoint());
                }
            }
                break;
            }
        }
    } else if (!ctrlPressed && e.isPopupTrigger() && this.application.allowPopupTrigger()) {
        this.application.processHexAction(this.hexMapPanel, e, HexAction.POPUP_TRIGGER,
                this.hexMapPanel.getHexPosition(e.getPoint()));
    } else if (e.getButton() == MouseEvent.BUTTON3) {
        this.dragging = true;
        this.hexMapPanelDesktop.initDrag(e.getPoint());
    }
}

From source file:com.farouk.projectapp.FirstGUI.java

private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked
    jList1.clearSelection();//from   w ww.jav  a 2s. com
    int row = jTable2.getSelectedRow();
    String name = (jTable2.getModel().getValueAt(row, 0).toString());
    jLabel15.setText("Selected company : '" + name + "'.    " + SQLConnect.checkIfAutomated(userID, name));
    if (jTabbedPane1.getSelectedIndex() == 0) {
        jButton10.setVisible(true);
        jButton7.setVisible(true);
        if (SQLConnect.ifAutomated(userID, name) == 1) {
            jButton15.setText("De-Auto");
        } else if (SQLConnect.ifAutomated(userID, name) == 0) {
            jButton15.setText("Automate");
        }
        if (SQLConnect.ifAutomated(userID, name) == 2) {
            jButton19.setText("De-Alert");
        } else {
            jButton19.setText("Alert");
        }
        jButton15.setVisible(true);
        if (SQLConnect.ifReported(userID, name) == 1) {
            jButton3.setText("Unreport");
        } else {
            jButton3.setText("Report");
        }

        jButton3.setVisible(true);
        jPanel10.setVisible(false);
        StringThirdParty = name;
        jTextField6.setText(name);
    }
    try {
        if (evt.getButton() == MouseEvent.BUTTON3) {

            int decision = JOptionPane.showConfirmDialog(rootPane, "Do you really want to delete " + name + "?",
                    "Remove a company", JOptionPane.YES_NO_OPTION);
            if (decision == JOptionPane.YES_OPTION) {
                SQLConnect.removeCompanyFromPortfolio(name, userID);
                UpdatejTable2();
                SQLConnect.registerTotalChanges(userID, total);
            }

        }
    } catch (Exception e) {
        System.err.println(e);
    }

}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

@Override
public void mouseReleased(final MouseEvent e) {
    if (this.application == null) {
        if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == 0 && e.isPopupTrigger()) {
            final HexPosition hexNumber = this.hexMapPanel.getHexPosition(e.getPoint());
            onPopup(e.getPoint(), hexNumber);
        } else {//from w ww.ja va2  s  .  co m
            switch (e.getButton()) {
            case MouseEvent.BUTTON3: {
                this.dragging = false;
                this.hexMapPanelDesktop.endDrag();
            }
                break;
            }
        }
    } else if (e.getButton() == MouseEvent.BUTTON3) {
        this.dragging = false;
        this.hexMapPanelDesktop.endDrag();
    }
}

From source file:Clavis.Windows.WShedule.java

public synchronized void create() {
    initComponents();//from   w  ww .java 2 s.c om
    this.setModal(true);
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            close();
        }
    });
    this.setTitle(lingua.translate("Registos de emprstimo para o recurso") + ": "
            + lingua.translate(mat.getTypeOfMaterialName()).toLowerCase() + " "
            + lingua.translate(mat.getDescription()));
    KeyQuest.addtoPropertyListener(jPanelInicial, true);
    String dat = new TimeDate.Date().toString();
    String[] auxiliar = prefs.get("datainicio", dat).split("/");
    if (auxiliar[0].length() > 1) {
        if (auxiliar[0].charAt(0) == '0') {
            auxiliar[0] = auxiliar[0].replaceFirst("0", "");
        }
    }
    if (auxiliar[1].length() > 1) {
        if (auxiliar[1].charAt(0) == '0') {
            auxiliar[1] = auxiliar[1].replaceFirst("0", "");
        }
    }
    if (auxiliar[2].length() > 1) {
        if (auxiliar[2].charAt(0) == '0') {
            auxiliar[2] = auxiliar[2].replaceFirst("0", "");
        }
    }
    inicio = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]),
            Integer.valueOf(auxiliar[2]));
    auxiliar = prefs.get("datafim", dat).split("/");
    if (auxiliar[0].length() > 1) {
        if (auxiliar[0].charAt(0) == '0') {
            auxiliar[0] = auxiliar[0].replaceFirst("0", "");
        }
    }
    if (auxiliar[1].length() > 1) {
        if (auxiliar[1].charAt(0) == '0') {
            auxiliar[1] = auxiliar[1].replaceFirst("0", "");
        }
    }
    if (auxiliar[2].length() > 1) {
        if (auxiliar[2].charAt(0) == '0') {
            auxiliar[2] = auxiliar[2].replaceFirst("0", "");
        }
    }
    fim = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]),
            Integer.valueOf(auxiliar[2]));

    SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy");
    Date date;
    try {
        date = sdf.parse(fim.toString());
    } catch (ParseException ex) {
        date = new Date();

    }
    jXDatePickerFim.setDate(date);
    try {
        date = sdf.parse(inicio.toString());
    } catch (ParseException ex) {
        date = new Date();
    }
    jXDatePickerInicio.setDate(date);
    andamento = 0;
    if (DataBase.DataBase.testConnection(url)) {
        DataBase.DataBase db = new DataBase.DataBase(url);
        java.util.List<Keys.Request> requisicoes = Clavis.RequestList
                .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim));
        db.close();
        estado = lingua.translate("Todos");
        DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
        if (requisicoes.size() > 0) {
            valores = new String[requisicoes.size()][4];
            lista = new java.util.ArrayList<>();
            requisicoes.stream().map((req) -> {
                if (mat.getMaterialTypeID() == 1) {
                    valores[andamento][0] = req.getPerson().getName();
                    valores[andamento][1] = req.getTimeBegin().toString(0) + " - "
                            + req.getTimeEnd().toString(0);
                    valores[andamento][2] = req.getBeginDate().toString();
                    String[] multipla = req.getActivity().split(":::");
                    if (multipla.length > 1) {
                        Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                        pop.create();
                        jTable1.addMouseListener(new MouseAdapter() {
                            int x = andamento;
                            int y = 3;

                            @Override
                            public void mousePressed(MouseEvent e) {
                                if (e.getButton() == MouseEvent.BUTTON1) {
                                    int row = jTable1.rowAtPoint(e.getPoint());
                                    int col = jTable1.columnAtPoint(e.getPoint());
                                    if ((row == x) && (col == y)) {
                                        pop.show(e.getComponent(), e.getX(), e.getY());
                                    }
                                }
                            }

                            @Override
                            public void mouseReleased(MouseEvent e) {
                                if (e.getButton() == MouseEvent.BUTTON1) {
                                    if (pop.isShowing()) {
                                        pop.setVisible(false);
                                    }
                                }
                            }
                        });
                        valores[andamento][3] = lingua.translate(multipla[0]) + "";
                    } else {
                        valores[andamento][3] = lingua.translate(req.getActivity());
                    }
                    if (valores[andamento][3].equals("")) {
                        valores[andamento][3] = lingua.translate("Sem descrio");
                    }
                    Object[] ob = { req.getPerson().getName(),
                            req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0),
                            req.getBeginDate().toString(), valores[andamento][3], req.getSubject().getName() };
                    modelo.addRow(ob);
                } else {
                    valores[andamento][0] = req.getPerson().getName();
                    valores[andamento][1] = req.getBeginDate().toString();
                    valores[andamento][2] = req.getEndDate().toString();
                    String[] multipla = req.getActivity().split(":::");
                    if (multipla.length > 1) {
                        Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                        pop.create();
                        jTable1.addMouseListener(new MouseAdapter() {
                            int x = andamento;
                            int y = 3;

                            @Override
                            public void mousePressed(MouseEvent e) {
                                if (e.getButton() == MouseEvent.BUTTON1) {
                                    int row = jTable1.rowAtPoint(e.getPoint());
                                    int col = jTable1.columnAtPoint(e.getPoint());
                                    if ((row == x) && (col == y)) {
                                        pop.show(e.getComponent(), e.getX(), e.getY());
                                    }
                                }
                            }

                            @Override
                            public void mouseReleased(MouseEvent e) {
                                if (e.getButton() == MouseEvent.BUTTON1) {
                                    if (pop.isShowing()) {
                                        pop.setVisible(false);
                                    }
                                }
                            }
                        });
                        valores[andamento][3] = multipla[0];
                    } else {
                        valores[andamento][3] = lingua.translate(req.getActivity());
                    }
                    if (valores[andamento][3].equals("")) {
                        valores[andamento][3] = lingua.translate("Sem descrio");
                    }
                    Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(),
                            req.getEndDate().toString(), valores[andamento][3] };
                    modelo.addRow(ob);
                }
                return req;
            }).map((req) -> {
                lista.add(req);
                return req;
            }).forEach((_item) -> {
                andamento++;
            });
        }
    }
    jComboBoxEstado.setSelectedIndex(prefs.getInt("comboboxvalue", 0));
    String[] opcoes = { lingua.translate("Ver detalhes da requisio"),
            lingua.translate("Ver requisices com a mesma data"),
            lingua.translate("Ver requisices com o mesmo estado") };
    ActionListener[] eventos = new ActionListener[opcoes.length];
    eventos[0] = (ActionEvent r) -> {
        Border border = BorderFactory.createCompoundBorder(
                BorderFactory.createCompoundBorder(new org.jdesktop.swingx.border.DropShadowBorder(Color.BLACK,
                        3, 0.5f, 6, false, false, true, true), BorderFactory.createLineBorder(Color.BLACK, 1)),
                BorderFactory.createEmptyBorder(0, 10, 0, 10));
        int val = jTable1.getSelectedRow();
        Keys.Request req = lista.get(val);
        javax.swing.JPanel pan = new javax.swing.JPanel(null);
        pan.setPreferredSize(new Dimension(500, 300));
        pan.setBounds(0, 20, 500, 400);
        pan.setBackground(Components.MessagePane.BACKGROUND_COLOR);
        javax.swing.JLabel lrecurso1 = new javax.swing.JLabel(lingua.translate("Recurso") + ": ");
        lrecurso1.setBounds(10, 20, 120, 26);
        lrecurso1.setFocusable(true);
        lrecurso1.setHorizontalAlignment(javax.swing.JLabel.LEFT);
        pan.add(lrecurso1);
        javax.swing.JLabel lrecurso11 = new javax.swing.JLabel(
                lingua.translate(req.getMaterial().getTypeOfMaterialName()) + " "
                        + lingua.translate(req.getMaterial().getDescription()));
        lrecurso11.setBounds(140, 20, 330, 26);
        lrecurso11.setBorder(border);
        pan.add(lrecurso11);
        javax.swing.JLabel lrecurso2 = new javax.swing.JLabel(lingua.translate("Utilizador") + ": ");
        lrecurso2.setBounds(10, 50, 120, 26);
        lrecurso2.setFocusable(true);
        lrecurso2.setHorizontalAlignment(javax.swing.JLabel.LEFT);
        pan.add(lrecurso2);
        javax.swing.JLabel lrecurso22 = new javax.swing.JLabel(req.getPerson().getName());
        lrecurso22.setBounds(140, 50, 330, 26);
        lrecurso22.setBorder(border);
        pan.add(lrecurso22);
        javax.swing.JLabel lrecurso3 = new javax.swing.JLabel(lingua.translate("Data inicial") + ": ");
        lrecurso3.setBounds(10, 80, 120, 26);
        lrecurso3.setFocusable(true);
        lrecurso3.setHorizontalAlignment(javax.swing.JLabel.LEFT);
        pan.add(lrecurso3);
        javax.swing.JLabel lrecurso33 = new javax.swing.JLabel(
                req.getBeginDate().toStringWithMonthWord(lingua));
        lrecurso33.setBounds(140, 80, 330, 26);
        lrecurso33.setBorder(border);
        pan.add(lrecurso33);
        javax.swing.JLabel lrecurso4 = new javax.swing.JLabel(lingua.translate("Data final") + ": ");
        lrecurso4.setBounds(10, 110, 120, 26);
        lrecurso4.setFocusable(true);
        lrecurso4.setHorizontalAlignment(javax.swing.JLabel.LEFT);
        pan.add(lrecurso4);
        javax.swing.JLabel lrecurso44 = new javax.swing.JLabel(req.getEndDate().toStringWithMonthWord(lingua));
        lrecurso44.setBounds(140, 110, 330, 26);
        lrecurso44.setBorder(border);
        pan.add(lrecurso44);

        javax.swing.JLabel lrecurso5 = new javax.swing.JLabel(lingua.translate("Atividade") + ": ");
        lrecurso5.setBounds(10, 140, 120, 26);
        lrecurso5.setFocusable(true);
        lrecurso5.setHorizontalAlignment(javax.swing.JLabel.LEFT);
        pan.add(lrecurso5);
        javax.swing.JLabel lrecurso55;
        if (req.getActivity().equals("")) {
            lrecurso55 = new javax.swing.JLabel(lingua.translate("Sem descrio"));
        } else {
            String[] saux = req.getActivity().split(":::");
            String atividade;
            boolean situacao = false;
            if (saux.length > 1) {
                situacao = true;
                atividade = saux[0];
            } else {
                atividade = req.getActivity();
            }
            if (req.getSubject().getId() > 0) {
                lrecurso55 = new javax.swing.JLabel(
                        lingua.translate(atividade) + ": " + req.getSubject().getName());
            } else {
                lrecurso55 = new javax.swing.JLabel(lingua.translate(atividade));
            }
            if (situacao) {
                Components.PopUpMenu pop = new Components.PopUpMenu(saux, lingua);
                pop.create();
                lrecurso55.addMouseListener(new MouseAdapter() {

                    @Override
                    public void mouseEntered(MouseEvent e) {
                        pop.show(e.getComponent(), e.getX(), e.getY());
                    }

                    @Override
                    public void mouseExited(MouseEvent e) {
                        pop.setVisible(false);
                    }

                });
            }
        }
        lrecurso55.setBounds(140, 140, 330, 26);
        lrecurso55.setBorder(border);
        pan.add(lrecurso55);
        int distancia = 170;
        if (req.getBeginDate().isBigger(req.getEndDate()) == 0) {
            javax.swing.JLabel lrecurso6 = new javax.swing.JLabel(lingua.translate("Horrio") + ": ");
            lrecurso6.setBounds(10, distancia, 120, 26);
            lrecurso6.setFocusable(true);
            lrecurso6.setHorizontalAlignment(javax.swing.JLabel.LEFT);
            pan.add(lrecurso6);
            javax.swing.JLabel lrecurso66 = new javax.swing.JLabel(
                    req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0));
            lrecurso66.setBounds(140, distancia, 330, 26);
            lrecurso66.setBorder(border);
            pan.add(lrecurso66);
            distancia = 200;
        }
        if (req.getBeginDate().isBigger(req.getEndDate()) == 0) {
            javax.swing.JLabel lrecurso7 = new javax.swing.JLabel(lingua.translate("Dia da semana") + ": ");
            lrecurso7.setBounds(10, distancia, 120, 26);
            lrecurso7.setFocusable(true);
            lrecurso7.setHorizontalAlignment(javax.swing.JLabel.LEFT);
            pan.add(lrecurso7);
            javax.swing.JLabel lrecurso77 = new javax.swing.JLabel(
                    lingua.translate(req.getWeekDay().perDayName()));
            lrecurso77.setBounds(140, distancia, 330, 26);
            lrecurso77.setBorder(border);
            pan.add(lrecurso77);
            if (distancia == 200) {
                distancia = 230;
            } else {
                distancia = 200;
            }
        }
        if (req.isTerminated() || req.isActive()) {
            javax.swing.JLabel lrecurso8 = new javax.swing.JLabel(lingua.translate("Levantamento") + ": ");
            lrecurso8.setBounds(10, distancia, 120, 26);
            lrecurso8.setFocusable(true);
            lrecurso8.setHorizontalAlignment(javax.swing.JLabel.LEFT);
            pan.add(lrecurso8);
            javax.swing.JLabel lrecurso88;
            if ((req.getLiftDate() != null) && (req.getLiftTime() != null)) {
                lrecurso88 = new javax.swing.JLabel(req.getLiftDate().toString() + " " + lingua.translate("s")
                        + " " + req.getLiftTime().toString(0));
            } else {
                lrecurso88 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar"));
            }
            lrecurso88.setBounds(140, distancia, 330, 26);
            lrecurso88.setBorder(border);
            pan.add(lrecurso88);
            switch (distancia) {
            case 200:
                distancia = 230;
                break;
            case 230:
                distancia = 260;
                break;
            default:
                distancia = 200;
                break;
            }
        }
        if (req.isTerminated()) {
            javax.swing.JLabel lrecurso9 = new javax.swing.JLabel(lingua.translate("Entrega") + ": ");
            lrecurso9.setBounds(10, distancia, 120, 26);
            lrecurso9.setFocusable(true);
            lrecurso9.setHorizontalAlignment(javax.swing.JLabel.LEFT);
            pan.add(lrecurso9);
            javax.swing.JLabel lrecurso99;
            if ((req.getDeliveryDate() != null) && (req.getDeliveryTime() != null)) {
                lrecurso99 = new javax.swing.JLabel(req.getDeliveryDate().toString() + " "
                        + lingua.translate("s") + " " + req.getDeliveryTime().toString(0));
            } else {
                lrecurso99 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar"));
            }
            lrecurso99.setBounds(140, distancia, 330, 26);
            lrecurso99.setBorder(border);
            pan.add(lrecurso99);
            switch (distancia) {
            case 200:
                distancia = 230;
                break;
            case 230:
                distancia = 260;
                break;
            case 260:
                distancia = 290;
                break;
            default:
                distancia = 200;
                break;
            }
        }
        Components.MessagePane mensagem = new Components.MessagePane(this, Components.MessagePane.INFORMACAO,
                Clavis.KeyQuest.getSystemColor(), lingua.translate(""), 500, 400, pan, "",
                new String[] { lingua.translate("Voltar") });
        mensagem.showMessage();
    };
    eventos[1] = (ActionEvent r) -> {
        String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 2).toString();
        SimpleDateFormat sdf_auxiliar = new SimpleDateFormat("dd/MM/yyyy");
        Date data_auxiliar;
        try {
            data_auxiliar = sdf_auxiliar.parse(val);
            Calendar cal = Calendar.getInstance();
            cal.setTime(data_auxiliar);
            int dia = cal.get(Calendar.DAY_OF_MONTH);
            int mes = cal.get(Calendar.MONTH) + 1;
            int ano = cal.get(Calendar.YEAR);
            inicio = new TimeDate.Date(dia, mes, ano);
            fim = new TimeDate.Date(dia, mes, ano);
        } catch (ParseException ex) {
            data_auxiliar = new Date();
        }
        jXDatePickerFim.setDate(data_auxiliar);
        jXDatePickerInicio.setDate(data_auxiliar);
        refreshTable(jComboBoxEstado.getSelectedIndex());
    };
    eventos[2] = (ActionEvent r) -> {
        String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 3).toString();
        for (int i = 0; i < jComboBoxEstado.getItemCount(); i++) {
            if (jComboBoxEstado.getItemAt(i).equals(val)) {
                jComboBoxEstado.setSelectedIndex(i);
            }
        }
    };
    KeyStroke[] strokes = new KeyStroke[opcoes.length];
    strokes[0] = KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.CTRL_MASK);
    strokes[1] = KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK);
    strokes[2] = KeyStroke.getKeyStroke(KeyEvent.VK_E, Event.CTRL_MASK);
    Components.PopUpMenu pop = new Components.PopUpMenu(opcoes, eventos, strokes);
    pop.create();
    mouseaction = new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY());
            if (jTable1.rowAtPoint(ponto) > -1) {
                jTable1.setRowSelectionInterval(jTable1.rowAtPoint(ponto),
                        jTable1.rowAtPoint(new java.awt.Point(e.getX(), e.getY())));
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                if (jTable1.getSelectedRow() >= 0) {
                    java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY());
                    if (jTable1.rowAtPoint(ponto) > -1) {
                        pop.show(e.getComponent(), e.getX(), e.getY());
                    }
                }
            }
        }

    };
    jTable1.addMouseListener(mouseaction);
}

From source file:GUI.MainWindow.java

private void VulnReferencesListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_VulnReferencesListMouseClicked

    int clicked = evt.getButton();
    if (clicked == MouseEvent.BUTTON1 && evt.getClickCount() == 2) {
        // A double click. Lets see if there is already a link or if we are creating a new one
        Object obj = VulnReferencesList.getSelectedValue();
        if (obj == null) {
            // We should simply show the 'add reference' prompy
        } else if (obj instanceof Reference) {
            // User probably wants to edit the existing reference
            Reference ref = (Reference) obj;
            addReference(VulnTree, VulnReferencesList, ref);
        }/*from  w  ww . j ava  2  s. co m*/
    } else if (clicked == MouseEvent.BUTTON3) {
        // A right click. Show the context menu
        //int selected = VulnReferencesList.getSelectedIndex();
        List l = VulnReferencesList.getSelectedValuesList();
        int selected = l.size();

        System.out.println("selected: " + selected);
        // None are selected enable insert and disable all the rest
        InsertReference.setEnabled(true);
        EditReferenceOption.setEnabled(false);
        LaunchInBrowser.setEnabled(false);
        DeleteReferenceOption.setEnabled(false);

        if (selected == 1) {
            // One was selected to enable the right options
            InsertReference.setEnabled(true);
            EditReferenceOption.setEnabled(true);
            LaunchInBrowser.setEnabled(true);
            DeleteReferenceOption.setEnabled(true);
        } else if (selected >= 2) {
            // One was selected to enable the right options
            InsertReference.setEnabled(true);
            EditReferenceOption.setEnabled(false);
            LaunchInBrowser.setEnabled(true);
            DeleteReferenceOption.setEnabled(true);
        }

        VulnReferencesContextMenu.show((Component) evt.getSource(), evt.getX(), evt.getY());
    }
}

From source file:neembuu.uploader.NeembuuUploader.java

/**
 * Opens up the Popup Menu//from  www .  ja v  a2 s . co  m
 *
 * @param evt
 */
private void openPopup(MouseEvent evt) {
    //The above three mouse events call this method.
    //So check which one will trigger Rightclick menu depending on os and use it.
    if (evt.isPopupTrigger()) {
        //Check if it is right click.
        if (evt.getButton() == java.awt.event.MouseEvent.BUTTON3) {
            NULogger.getLogger().info("RightClick event");
            //if already 2 or more rows selected, leave it.
            //EDIT: After some days I forgot what this code does,.. This is copied from a stackoverflow post actually..
            //But it's an unchangeable code and will just work forever, so I'm not gonna mess with it.
            if (neembuuUploaderTable.getSelectedRowCount() < 2) {
                int r = neembuuUploaderTable.rowAtPoint(evt.getPoint());
                if (r >= 0 && r < neembuuUploaderTable.getRowCount()) {
                    neembuuUploaderTable.setRowSelectionInterval(r, r);
                } else {
                    neembuuUploaderTable.clearSelection();
                }

                int rowindex = neembuuUploaderTable.getSelectedRow();
                if (rowindex < 0) {
                    return;
                }
            }
            //Display the popup menu on the exact point of right click.
            PopupBuilder.getInstance().show(evt.getComponent(), evt.getX(), evt.getY());
        }
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void contentPanel_mouseClicked(MouseEvent event) {
    if (event.getButton() == MouseEvent.BUTTON3) {
        contentPanel.setBackground(//from w ww  .  ja va2  s. co m
                JColorChooser.showDialog(this, "Choose Background Color", contentPanel.getBackground()));
    }
}