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:com.puzzle.gui.MainFrame.java

public void trayIconMouseClick(MouseEvent e) {
    if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1)//?  
    {//from  w w w. j  a v  a2 s  .c  o  m
        this.setExtendedState(JFrame.NORMAL);//?  
        this.setVisible(true);//  
    }
}

From source file:components.GlassPaneDemo.java

private void redispatchMouseEvent(MouseEvent e, boolean repaint) {
    Point glassPanePoint = e.getPoint();
    Container container = contentPane;
    Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane);
    if (containerPoint.y < 0) { //we're not in the content pane
        if (containerPoint.y + menuBar.getHeight() >= 0) {
            //The mouse event is over the menu bar.
            //Could handle specially.
        } else {// w w w  .ja  v  a  2  s.  c o m
            //The mouse event is over non-system window 
            //decorations, such as the ones provided by
            //the Java look and feel.
            //Could handle specially.
        }
    } else {
        //The mouse event is probably over the content pane.
        //Find out exactly which component it's over.  
        Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x,
                containerPoint.y);

        if ((component != null) && (component.equals(liveButton))) {
            //Forward events over the check box.
            Point componentPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, component);
            component.dispatchEvent(new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(),
                    componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger()));
        }
    }

    //Update the glass pane if requested.
    if (repaint) {
        glassPane.setPoint(glassPanePoint);
        glassPane.repaint();
    }
}

From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.java

private void makeAttributesTable() {
    setEventAttributes(null, true);/*from   w ww  .j  a  v a2 s  . c o  m*/

    // listen for trigger button and double click to edit channel.
    eventAttributesTable.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            if (eventAttributesTable.rowAtPoint(new Point(evt.getX(), evt.getY())) == -1) {
                return;
            }

            if (evt.getClickCount() >= 2) {
                new ViewContentDialog((String) eventAttributesTable.getModel().getValueAt(
                        eventAttributesTable.getSelectedModelIndex(), ATTRIBUTES_VALUE_COLUMN_NUMBER));
            }
        }
    });

    eventAttributesTable.setSelectionMode(0);

    // Disable HTML in a column.
    DefaultTableCellRenderer noHTMLRenderer = new DefaultTableCellRenderer();
    noHTMLRenderer.putClientProperty("html.disable", Boolean.TRUE);
    eventAttributesTable.getColumnExt(ATTRIBUTES_VALUE_COLUMN_NAME).setCellRenderer(noHTMLRenderer);

    eventAttributesPane.setViewportView(eventAttributesTable);
}

From source file:GlassPaneDemo.java

private void redispatchMouseEvent(MouseEvent e, boolean repaint) {
    Point glassPanePoint = e.getPoint();
    Container container = contentPane;
    Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane);
    if (containerPoint.y < 0) { // we're not in the content pane
        if (containerPoint.y + menuBar.getHeight() >= 0) {
            // The mouse event is over the menu bar.
            // Could handle specially.
        } else {/*from  ww w  . ja  va  2  s.  co  m*/
            // The mouse event is over non-system window
            // decorations, such as the ones provided by
            // the Java look and feel.
            // Could handle specially.
        }
    } else {
        // The mouse event is probably over the content pane.
        // Find out exactly which component it's over.
        Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x,
                containerPoint.y);

        if ((component != null) && (component.equals(liveButton))) {
            // Forward events over the check box.
            Point componentPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, component);
            component.dispatchEvent(new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(),
                    componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger()));
        }
    }

    // Update the glass pane if requested.
    if (repaint) {
        glassPane.setPoint(glassPanePoint);
        glassPane.repaint();
    }
}

From source file:nosqltools.MainForm.java

public void connect() {
    String user;/*from  www  .ja v a2s.c o m*/
    String pass;
    String dbname;
    String serveradd;
    int port;

    LoginDialog dlg_login = new LoginDialog(null);
    dlg_login.setVisible(true);

    //If user chose login and not cancel option on dialog box
    if (dlg_login.isToLogin()) {
        Text_MessageBar.setText(Initializations.DBATTEMPTING);
        Text_MessageBar.setForeground(Color.ORANGE);
        user = dlg_login.getUsername();
        pass = dlg_login.getPassword();
        dbname = dlg_login.getDatabase();
        serveradd = dlg_login.getServerAddr();
        port = dlg_login.getPort();

        if (dbcon.connect(user, pass, dbname, serveradd, port)) {
            DefaultTreeModel defTableMod = dbcon.buildDBTree();
            if (defTableMod != null && dbcon.isConnectionSuccess()) {
                jTree1.setModel(defTableMod);
                Text_MessageBar.setText(Initializations.DBCONNSUCCESS);
                Text_MessageBar.setForeground(Color.GREEN);
                Menu_Collections.setEnabled(true);

                //load the data of collection in panel_text on double click
                jTree1.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent me) {
                        if (me.getButton() == MouseEvent.BUTTON1) {
                            if (me.getClickCount() == 2) {
                                //get the path of the mouse click ex:[localhost,test,testData] 
                                Op_Refresh.setEnabled(true);
                                tp = jTree1.getPathForLocation(me.getX(), me.getY());
                                if (tp != null) {
                                    List<String> coll_db = dbcon.getAllCollections();
                                    int cnt = tp.getPathCount();
                                    for (int i = 0; i < cnt; i++) {
                                        //if one of the collection matches the coll that was clicked by the user load data
                                        if (coll_db.contains(tp.getPathComponent(i).toString())) {
                                            indexOfCurrentCollection = i;
                                            sb = dbcon.getCollectionData(tp.getPathComponent(i).toString());

                                            if (sb != null) {
                                                Panel_Text.setVisible(true);

                                                JsonNode jNode1;
                                                try {
                                                    jNode1 = mapper.readTree(sb.toString());
                                                    textArea.setText(mapper.writerWithDefaultPrettyPrinter()
                                                            .writeValueAsString(jNode1));
                                                } catch (IOException ex) {
                                                    Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE,
                                                            null, ex);
                                                }

                                                Text_MessageBar.setText(Initializations.INITSTRING);
                                                // textArea.setText(sb.toString());
                                                validateDataPanel_text(sb);
                                                /*
                                                if (json_util.isValid(sb.toString())) 
                                                {
                                                    json_util.isDataParsed(textArea.getText());
                                                    Text_MessageBar.setText(Initializations.JSONFILESUCCESS);
                                                } 
                                                else 
                                                {
                                                    sb.setLength(0);
                                                    //JOptionPane.showMessageDialog(this, Initializations.JSONINCORRECTFORMAT , Initializations.VALIDATIONERROR , JOptionPane.ERROR_MESSAGE);
                                                        
                                                    try
                                                    {
                                                Object obj = parser.parse(sb.toString());
                                                    }
                                                    catch(org.json.simple.parser.ParseException pe)
                                                    {
                                                       Text_MessageBar.setText(Initializations.ERRORLINE + json_util.getLineNumber(pe.getPosition(), textArea.getText()) + " - " + pe);
                                                    }
                                                } */
                                            } else {
                                                Panel_Text.setVisible(false);
                                                Text_MessageBar.setText(Initializations.SYSTEMCOLL);
                                                Text_MessageBar.setForeground(Color.RED);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                });
            } else {
                jTree1.setModel(null);
                Text_MessageBar.setText(Initializations.DBCONNFAIL);
                Text_MessageBar.setForeground(Color.RED);
            }
        } else {
            jTree1.setModel(null);
            Text_MessageBar.setText(Initializations.DBCONNFAIL);
            Text_MessageBar.setForeground(Color.RED);
        }
    } else {
        jTree1.setModel(null);
        Text_MessageBar.setText(Initializations.DBCONNFAIL);
        Text_MessageBar.setForeground(Color.RED);
    }

}

From source file:net.sf.xmm.moviemanager.gui.DialogIMDB.java

JPanel createMoviehitsList() {
    /* Movies List panel...*/
    JPanel panelMoviesList = new JPanel();
    panelMoviesList.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
                    Localizer.get("DialogIMDB.panel-movie-list.title")), //$NON-NLS-1$
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    listMovies = new JList() {

        public String getToolTipText(MouseEvent e) {

            if (getCellBounds(0, 0) == null)
                return null;

            String retVal = null;

            int row = (int) e.getPoint().getY() / (int) getCellBounds(0, 0).getHeight();

            if (row >= 0 && row < getModel().getSize()
                    && getMoviesList().getModel().getElementAt(row) instanceof ModelIMDbSearchHit) {
                retVal = ((ModelIMDbSearchHit) getMoviesList().getModel().getElementAt(row)).getAka();

                if (retVal != null && retVal.trim().equals("")) //$NON-NLS-1$
                    retVal = null;//  ww  w. j a v  a 2s  .c  om
            }

            return retVal;
        }

        public JToolTip createToolTip() {
            JMultiLineToolTip tooltip = new JMultiLineToolTip();
            tooltip.setComponent(this);
            return tooltip;
        }
    };

    // Unfortunately setting tooltip timeout affects ALL tooltips
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.registerComponent(listMovies);
    ttm.setInitialDelay(0);
    ttm.setReshowDelay(0);

    listMovies.setFixedCellHeight(18);

    listMovies.setFont(new Font(listMovies.getFont().getName(), Font.PLAIN, listMovies.getFont().getSize()));
    listMovies.setLayoutOrientation(JList.VERTICAL);
    listMovies.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listMovies.setCellRenderer(new MovieHitListCellRenderer());

    listMovies.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent event) {

            // Open we page
            if (SwingUtilities.isRightMouseButton(event)) {

                int index = listMovies.locationToIndex(event.getPoint());

                if (index >= 0) {
                    ModelIMDbSearchHit hit = (ModelIMDbSearchHit) listMovies.getModel().getElementAt(index);

                    if (hit.getUrlID() != null && !hit.getUrlID().equals("")) {
                        BrowserOpener opener = new BrowserOpener(hit.getCompleteUrl());
                        opener.executeOpenBrowser(MovieManager.getConfig().getSystemWebBrowser(),
                                MovieManager.getConfig().getBrowserPath());
                    }
                }
            } else if (SwingUtilities.isLeftMouseButton(event) && event.getClickCount() >= 2) {
                buttonSelect.doClick();
            }
        }
    });

    KeyStroke enterKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);
    ActionListener listKeyBoardActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            log.debug("ActionPerformed: " + "Movielist - ENTER pressed."); //$NON-NLS-1$
            buttonSelect.doClick();
        }
    };
    listMovies.registerKeyboardAction(listKeyBoardActionListener, enterKeyStroke, JComponent.WHEN_FOCUSED);

    JScrollPane scrollPaneMovies = new JScrollPane(listMovies);
    scrollPaneMovies.setAutoscrolls(true);
    //scrollPaneMovies.registerKeyboardAction(listKeyBoardActionListener,enterKeyStroke, JComponent.WHEN_FOCUSED);

    panelMoviesList.setLayout(new BorderLayout());
    panelMoviesList.add(scrollPaneMovies, BorderLayout.CENTER);

    return panelMoviesList;
}

From source file:view.MainWindow.java

private void jtExplorerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtExplorerMouseClicked
    if (2 == evt.getClickCount()) {
        if (jtExplorer.getSelectionRows().length != 0) {
            if (1 == jtExplorer.getSelectionRows().length && jtExplorer.getSelectionRows()[0] != 0) {
                // 1 ficheiro seleccionado
                File file = getSelectedFile(jtExplorer);
                if (file.exists() && file.isFile() && file.getAbsolutePath().endsWith(".pdf")) {
                    loadPdf(file, true);
                }/*from  ww  w  . j  a  v  a2s .  c  o m*/
            }
        }
    }
}

From source file:org.rdv.viz.image.ImageViz.java

private void initFilmstripPanel() {
    filmstripPanel = new FilmstripPanel();
    filmstripPanel.setBackground(Color.black);
    filmstripPanel.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent pce) {
            String propertyName = pce.getPropertyName();
            if (propertyName.equals(FilmstripPanel.MAXIMUM_IMAGES_PROPERTY)) {
                if (filmstripPanel.getMaximumImages() != FilmstripPanel.MAXIMUM_IMAGES_DEFAULT) {
                    properties.setProperty(DATA_PANEL_PROPERTY_MAXIMUM_FILMSTRIP_IMAGES,
                            pce.getNewValue().toString());
                } else {
                    properties.remove(DATA_PANEL_PROPERTY_MAXIMUM_FILMSTRIP_IMAGES);
                }//www. j a  v  a 2 s.  co m
                updateMaximumFilmstripImagesRadioButtons();
            }
        }
    });

    filmstripPanel.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
                setFilmstripMode(false);
            }
        }
    });
}

From source file:br.com.atmatech.sac.view.ViewListaAtendimento.java

private void jTatendimentoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTatendimentoMouseClicked
    // TODO add your handling code here:
    if (new NivelAcesso().getAcesso("ViewAtendimento", "acessar")) {
        if (evt.getClickCount() == 2) {
            ViewAtendimento view = new ViewAtendimento(viewprincipal, this, clickAtendimento(),
                    new UsuarioLogadoBeans().getAlttecnico(), false);
            viewprincipal.jTaabas.getSelectedIndex();
            viewprincipal.jTaabas.setComponentAt(viewprincipal.jTaabas.getSelectedIndex(), view);

            if (!new UsuarioLogadoBeans().getBconsulta()) {
                if (constecnico.isAlive()) {
                    if (!constecnico.isInterrupted()) {
                        constecnico.stop();
                    }//w ww. j a  v  a  2  s.c  o m
                }
                //constecnico.stop();
            }
        }
    }
    if (jTatendimento.getSelectedRow() >= 0) {
        if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {
            jPopupMenu1.show(jTatendimento, evt.getX(), evt.getY());
        }
    }
}

From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java

/**
 * Creates the tree view, that holds the data structure. <br>
 * <br>//  w w  w .  j  a  va  2  s.  co m
 * Initially, the root node is <b>not</b> visible, so that the tree appears empty at the beginning.
 */
private void createTree() {

    /**
     * Mouse listener to listen for mouse events on the tree. <br>
     * This will mark the selected tree entry as "selected" or "unselected",
     * which will cause this nodes checkbox to appear as either "checked" or
     * "unchecked".
     */
    treeMouseListener = new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            int x = e.getX();
            int y = e.getY();

            int row = tree.getRowForLocation(x, y);

            TreePath path = tree.getPathForRow(row);
            if (path != null) {
                CheckableTreeNode node = (CheckableTreeNode) path.getLastPathComponent();
                if (e.getClickCount() == 2) {
                    Object userObject = node.getUserObject();
                    if ((userObject instanceof FileNodeWrapper) && node.isLeaf()) {
                        FileNodeWrapper fnw = (FileNodeWrapper) userObject;
                        try {
                            JabRefDesktop.openExternalViewer(
                                    JabRefGUI.getMainFrame().getCurrentBasePanel().getBibDatabaseContext(),
                                    fnw.file.getAbsolutePath(), "pdf");
                        } catch (IOException e1) {
                            LOGGER.info("Error opening file", e1);
                        }
                    }
                } else {
                    node.check();
                    tree.invalidate();
                    tree.repaint();
                }
            }
        }

    };

    CheckableTreeNode startNode = new CheckableTreeNode("ROOT");
    DefaultTreeModel model = new DefaultTreeModel(startNode);

    tree.setModel(model);
    tree.setRootVisible(false);

    DefaultTreeCellRenderer renderer = new CheckboxTreeCellRenderer();
    tree.setCellRenderer(renderer);

    tree.addMouseListener(treeMouseListener);

}