Example usage for java.awt.event MouseEvent getClickCount

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

Introduction

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

Prototype

public int getClickCount() 

Source Link

Document

Returns the number of mouse clicks associated with this event.

Usage

From source file:dotaSoundEditor.Controls.EditorPanel.java

protected void attachDoubleClickListenerToTree() {
    MouseListener ml = new MouseAdapter() {
        @Override// w w w . j  av a  2 s. c o  m
        public void mousePressed(MouseEvent e) {
            int selRow = currentTree.getRowForLocation(e.getX(), e.getY());
            TreePath selPath = currentTree.getPathForLocation(e.getX(), e.getY());
            if (selRow != -1 && ((DefaultMutableTreeNode) selPath.getLastPathComponent()).isLeaf()) {
                if (e.getClickCount() == 2) {
                    playSelectedTreeSound(selPath, Paths.get(vpkPath));
                }
            }
        }
    };
    currentTree.addMouseListener(ml);
}

From source file:com.openbravo.pos.panels.JTicketsFinder.java

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

    if (evt.getClickCount() == 2) {
        selectedTicket = (FindTicketsInfo) jListTickets.getSelectedValue();
        if (parentComponent != null && parentComponent instanceof JTicketsBagTicket) {
            ((JTicketsBagTicket) parentComponent).readTicket(selectedTicket.getTicketId(),
                    selectedTicket.getTicketType());
        }/*from w  w w .j  a  va  2 s. c  om*/
    }

}

From source file:org.executequery.gui.editor.QueryEditorResultsPanel.java

public void tabSelected(MouseEvent e) {

    if (e.getClickCount() >= 2) {

        queryEditor.toggleResultPane();
    }

}

From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeoChooserDlg.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override/*  w  w  w  . jav  a  2  s. c o  m*/
public void createUI() {
    boolean doStatesOrCounties = doAllCountries[1] || doAllCountries[2] || doInvCountry[1] || doInvCountry[2];
    //this.whichBtns = doStatesOrCounties && !doInvCountry[1] && rankId > 200 ? CustomDialog.OKCANCELAPPLYHELP : CustomDialog.OKCANCELHELP;

    boolean isStCnty = true;//rankId > 200; 

    dataListModel = new DefaultListModel<GeoSearchResultsItem>();
    mainList = new JList<GeoSearchResultsItem>(dataListModel);
    JScrollPane sb = createScrollPane(mainList, true);

    String listDim;
    if (UIHelper.isWindows()) {
        listDim = "250px";
        Dimension sz = new Dimension(250, 250);
        mainList.setPreferredSize(sz);
        sb.setPreferredSize(sz);
    } else {
        listDim = "f:p:g";
    }

    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g",
            "p,2px,p,12px,p,2px," + listDim + ",8px,p,4px,p,10px,p" + (isStCnty ? ",8px,p" : "")));

    this.contentPanel = pb.getPanel();

    super.createUI();

    okBtn.setEnabled(false);

    calcProgress();

    try {
        if (coInfoList != null && coInfoList.size() > 0) {
            fillFromLuceneResults();
        } else {
            fillFromQuery();
        }

        mainList.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    getOkBtn().doClick();

                } else if (e.getClickCount() == 1 && !noMatchesFound && !mainList.isSelectionEmpty()) {
                    getOkBtn().setEnabled(true);
                }
            }
        });
        mainList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    listItemSelected();
                }
            }
        });

        updateNameCB = createCheckBox("Update the Name in the Geography tree."); // I18N
        //mergeCB      = createCheckBox("Merge all the geographies with the same name.");
        addISOCodeCB = createCheckBox("Add the ISO Code to the record");
        isoCodeTF = createTextField(8);
        isoCodeTF.setVisible(rankId < 400);

        updateNameCB.setSelected(isUpdateNamesChecked);
        //mergeCB.setSelected(true);
        addISOCodeCB.setSelected(true);

        updateNameCB.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(final ChangeEvent e) {
                isUpdateNamesChecked = updateNameCB.isSelected();
            }
        });

        DocumentListener dl = new DocumentAdaptor() {
            @Override
            protected void changed(DocumentEvent e) {
                okBtn.setEnabled(!isoCodeTF.getText().isEmpty());
            }
        };
        isoCodeTF.getDocument().addDocumentListener(dl);
        //labels.add(nameStr);// + "  (Unknown)");

        PanelBuilder lookPB = null;
        JButton lookupBtn = null;
        if (isStCnty) {
            lookPB = new PanelBuilder(new FormLayout("f:p:g,p", "p"));
            lookupBtn = createI18NButton("CLNUP_GEO_LOOK_UP_ISO");
            lookPB.add(lookupBtn, cc.xy(2, 1));
            lookupBtn.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    globalRankSearch();
                }
            });
        }

        int i = 0;
        ArrayList<String> labels = new ArrayList<String>();
        while (i < parentNames.length && parentRanks[i] > -1) {
            labels.add(i18NLabelsMap.get(parentRanks[i++]));
        }

        PanelBuilder pbTop = new PanelBuilder(
                new FormLayout("p,2px,f:p:g", UIHelper.createDuplicateJGoodiesDef("p", "2px", labels.size())));
        int y = 1;
        for (i = 0; i < labels.size(); i++) {
            JLabel lbl = createLabel(parentNames[i]);
            pbTop.add(createFormLabel(labels.get(i)), cc.xy(1, y));
            pbTop.add(lbl, cc.xy(3, y));
            lbl.setBackground(Color.WHITE);
            lbl.setOpaque(true);
            y += 2;
        }

        pb.add(pbTop.getPanel(), cc.xy(1, 3));
        pb.addSeparator("Possible standard Geography choices", cc.xy(1, 5)); // I18N
        pb.add(sb, cc.xy(1, 7));
        pb.add(updateNameCB, cc.xy(1, 9));

        PanelBuilder pbc = new PanelBuilder(new FormLayout("p,10px,p,f:p:g", "p"));
        pbc.add(addISOCodeCB, cc.xy(1, 1));
        pbc.add(isoCodeTF, cc.xy(3, 1));

        pb.add(pbc.getPanel(), cc.xy(1, 11));

        i = 13;
        if (isStCnty) {
            pb.add(lookPB.getPanel(), cc.xy(1, i));
            i += 2;
        }

        //if (doAllCountries[0])
        if (false) // hidding it for now
        {
            progressBar = new JProgressBar(0, 100);
            progressBar.setStringPainted(true);
            PanelBuilder prgPB = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p"));
            prgPB.add(createFormLabel("Progress"), cc.xy(1, 1));
            prgPB.add(progressBar, cc.xy(3, 1));
            pb.add(prgPB.getPanel(), cc.xy(1, i));
            i += 2;
        }

        mainList.setSelectedIndex(selectedIndex);
        mainList.ensureIndexIsVisible(selectedIndex);

        noMatchesFound = dataListModel.size() == 0;

        // Optional Depending on States / Countries
        if (doStatesOrCounties) {
            if (dataListModel.getSize() == 0) {
                dataListModel.addElement(new GeoSearchResultsItem("No matches found."));// I18N
            }
        }

        pb.setDefaultDialogBorder();

    } catch (Exception ex) {
        ex.printStackTrace();
    }

    if (UIHelper.isWindows()) {
        setResizable(false);
    }
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // Must be called at the end 'createUI'
}

From source file:de.tntinteractive.portalsammler.gui.DocumentTable.java

public DocumentTable(final Gui gui, final SecureStore store) {
    this.gui = gui;
    this.store = store;

    this.table = new JTable();
    this.table.setRowSelectionAllowed(true);
    this.refreshContents();
    this.table.addMouseListener(new MouseAdapter() {
        @Override/*from ww  w  .ja  v a 2s.com*/
        public void mousePressed(final MouseEvent me) {
            final int r = DocumentTable.this.table.rowAtPoint(me.getPoint());
            if (!DocumentTable.this.table.getSelectionModel().isSelectedIndex(r)) {
                if (r >= 0 && r < DocumentTable.this.table.getRowCount()) {
                    DocumentTable.this.table.setRowSelectionInterval(r, r);
                } else {
                    DocumentTable.this.table.clearSelection();
                }
            }

            if (me.isPopupTrigger()) {
                DocumentTable.this.showPopup(me);
            } else if (me.getClickCount() == 2) {
                DocumentTable.this.openSelectedRows();
            }
        }

        @Override
        public void mouseReleased(final MouseEvent me) {
            if (me.isPopupTrigger()) {
                DocumentTable.this.showPopup(me);
            }
        }
    });
    this.table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    this.table.getColumnModel().getColumn(0).setPreferredWidth(120);
    this.table.getColumnModel().getColumn(1).setPreferredWidth(80);
    this.table.getColumnModel().getColumn(2).setPreferredWidth(100);
    this.table.getColumnModel().getColumn(3).setPreferredWidth(500);
}

From source file:org.nuclos.client.ui.collect.searcheditor.SearchEditorController.java

/**
 * event: a mouse event occured on a node in the <code>view</code>
 * @param selPath the path of the node where the mouse event occured.
 * @param ev/*from   ww  w .j a  v a  2  s  . c  o  m*/
 */
private void mouseEventOnNode(TreePath selPath, MouseEvent ev) {
    final SearchConditionTreeNode node = (SearchConditionTreeNode) selPath.getLastPathComponent();
    final JTree tree = (JTree) ev.getComponent();

    // select the node:
    tree.setSelectionPath(selPath);

    if (ev.isPopupTrigger()) {
        // show popup menu:
        final JPopupMenu popupMenu = this.getPopupMenu(node, tree);
        if (popupMenu != null) {
            popupMenu.show(ev.getComponent(), ev.getX(), ev.getY());
        }
    } else if (ev.getID() == MouseEvent.MOUSE_CLICKED) {
        if (ev.getButton() == MouseEvent.BUTTON1) {
            if (ev.getClickCount() == 2) {
                if (this.clctfproviderfactory == null) {
                    throw new IllegalStateException(
                            "No CollectableFieldsProviderFactory was defined for the search editor.");
                }
                // perform the node's default action:
                final Action actDefault = node.getDefaultTreeNodeAction(tree, this.clcteRoot,
                        this.clctfproviderfactory, this.additionalFields);
                if (actDefault != null) {
                    actDefault.actionPerformed(null);
                }
            }
        }
    }
}

From source file:cish.CISH.java

private void jXTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jXTable1MouseClicked
    if (evt.getClickCount() == 2) {
        TMAspot ts = null;/*from  w  w  w . ja  v  a  2s .c  o  m*/
        String selectedName = jXTable1.getStringAt(jXTable1.getSelectedRow(),
                jXTable1.convertColumnIndexToView(0));
        for (TMAspot ts_ : manager.getTMAspots()) {
            if (ts_.getName().equals(selectedName)) {
                ts = ts_;
                break;
            }
        }
        manager.selectAndShowTMAspot(ts);
    }
}

From source file:edu.uchc.octane.OctaneWindowControl.java

/**
 * Constructor//from w  w  w .ja va 2s .  c  o  m
 *
 * @param imp the image
 */
public OctaneWindowControl(ImagePlus imp) {

    super();

    path_ = null;
    imp_ = imp;

    FileInfo fi = imp.getOriginalFileInfo();
    if (fi != null) {

        path_ = fi.directory;

    }

    imp.getCanvas().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {

            if (e.getClickCount() == 2) {

                findMolecule();

            }
        }
    });

}

From source file:net.sf.mzmine.chartbasics.gui.swing.ChartGestureMouseAdapter.java

@Override
public void mouseClicked(MouseEvent e) {
    if (gestureHandlers == null || gestureHandlers.isEmpty()
            || !(listensFor(Event.CLICK) || listensFor(Event.DOUBLE_CLICK)))
        return;//from   w w w .j  a va2  s  . co m

    if (e.getComponent() instanceof ChartPanel) {
        ChartPanel chartPanel = (ChartPanel) e.getComponent();
        ChartEntity entity = findChartEntity(chartPanel, e);
        ChartGesture.Entity gestureEntity = ChartGesture.getGestureEntity(entity);
        Button button = Button.getButton(e.getButton());

        if (!e.isConsumed()) {
            // double clicked
            if (e.getClickCount() == 2) {
                // reset click count to handle double clicks quickly
                e.consume();
                // handle event
                handleEvent(new ChartGestureEvent(chartPanel, e, entity,
                        new ChartGesture(gestureEntity, Event.DOUBLE_CLICK, button)));
            } else if (e.getClickCount() == 1) {
                // handle event
                handleEvent(new ChartGestureEvent(chartPanel, e, entity,
                        new ChartGesture(gestureEntity, Event.CLICK, button)));
            }
        }
    }
}

From source file:uk.ac.lkl.cram.ui.ModuleFrame.java

private JXTaskPane createLearnerFeedbackChartPane() {
    JXTaskPane feedbackChartPane = new JXTaskPane();
    feedbackChartPane.setScrollOnExpand(true);
    feedbackChartPane.setTitle("Learner Feedback");
    FeedbackChartMaker maker = new FeedbackChartMaker(module);
    final ChartPanel chartPanel = maker.getChartPanel();
    //Add a mouselistener, listening for a double click on a bar of the stacked bar
    chartPanel.addChartMouseListener(new ChartMouseListener() {
        @Override//w  ww.  j  a  v a2s  .c  om
        public void chartMouseClicked(ChartMouseEvent cme) {
            //Get the mouse event
            MouseEvent trigger = cme.getTrigger();
            //Test if the mouse event is a left-button
            if (trigger.getButton() == MouseEvent.BUTTON1 && trigger.getClickCount() == 2) {

                //Create a pop up dialog containing that the tlalineitems
                FeedbackPopupDialog popup = new FeedbackPopupDialog(
                        (Frame) SwingUtilities.getWindowAncestor(chartPanel), true, module.getTLALineItems());
                //Set the title of the popup 
                popup.setTitle("All Activities");
                //Centre the popup at the location of the mouse click
                Point location = trigger.getLocationOnScreen();
                int w = popup.getWidth();
                int h = popup.getHeight();
                popup.setLocation(location.x - w / 2, location.y - h / 2);
                popup.setVisible(true);
                int returnStatus = popup.getReturnStatus();
                if (returnStatus == LearningTypePopupDialog.RET_OK) {
                    modifyTLALineItem(popup.getSelectedTLALineItem(), 1);
                }
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
            //Set the cursor shape according to the location of the cursor
            if (cme.getEntity() instanceof CategoryItemEntity) {
                chartPanel.setCursor(HAND);
            } else {
                chartPanel.setCursor(Cursor.getDefaultCursor());
            }
        }
    });
    chartPanel.setPreferredSize(new Dimension(150, 200));
    feedbackChartPane.add(chartPanel);
    return feedbackChartPane;
}