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:savant.plugin.builtin.SavantFileRepositoryBrowser.java

public final Component getCenterPanel(List<TreeBrowserEntry> roots) {
    table = new TreeTable(new TreeBrowserModel(roots) {
        @Override/*from   w w w.  j  a  v a2  s . co  m*/
        public String[] getColumnNames() {
            return new String[] { "Name", "Description" };
        }
    });
    table.setSortable(true);
    table.setRespectRenderPreferredHeight(true);

    // configure the TreeTable
    table.setExpandAllAllowed(true);
    table.setShowTreeLines(false);
    table.setSortingEnabled(false);
    table.setRowHeight(18);
    table.setShowGrid(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.expandFirstLevel();
    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                actOnSelectedItem(true);
            }
        }
    });

    // do not select row when expanding a row.
    table.setSelectRowWhenToggling(false);

    table.getColumnModel().getColumn(0).setPreferredWidth(200);
    //table.getColumnModel().getColumn(1).setPreferredWidth(400);
    //table.getColumnModel().getColumn(2).setPreferredWidth(100);
    //table.getColumnModel().getColumn(3).setPreferredWidth(100);
    //table.getColumnModel().getColumn(4).setPreferredWidth(50);

    table.getColumnModel().getColumn(0).setCellRenderer(FILE_RENDERER);

    // add searchable feature
    TableSearchable searchable = new TableSearchable(table) {

        @Override
        protected String convertElementToString(Object item) {
            if (item instanceof TreeBrowserEntry) {
                return ((TreeBrowserEntry) item).getType();
            }
            return super.convertElementToString(item);
        }
    };
    searchable.setMainIndex(0); // only search for name column

    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.getViewport().setBackground(Color.WHITE);

    JPanel panel = new JPanel(new BorderLayout(6, 6));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setPreferredSize(new Dimension(800, 500));
    return panel;
}

From source file:com.akman.enjoyfood.SelectPrinters.java

private void tblPrintersMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblPrintersMouseClicked
    if (evt.getClickCount() == 2) {

    }//from   w  w  w .j a va  2  s  . co m
}

From source file:edu.scripps.fl.pubchem.xmltool.gui.PubChemXMLCreatorGUI.java

public void mouseClicked(MouseEvent e) {
    try {//from  w  w w. j  a  v  a2  s .co  m
        if (e.getClickCount() > 0) {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            if (e.getSource() == jtpExample) {
                URL url = getClass().getClassLoader().getResource("ExampleExcel.xlsx");
                File tmpFile = File.createTempFile("example", ".xlsx");
                FileUtils.copyURLToFile(url, tmpFile);
                tmpFile.deleteOnExit();
                Desktop.getDesktop().open(tmpFile);
            } else if (e.getSource() == jtpExcelTemplate) {
                File saveFile = gc.fileChooser(jtfFileExcel, ".xlsx", "save");
                if (saveFile != null) {
                    URL url = getClass().getClassLoader().getResource("ExcelTemplate_withBAO.xlsx");
                    OutputStream out = new FileOutputStream(saveFile, true);
                    IOUtils.copy(url.openStream(), out);
                    String output = FilenameUtils.concat(FilenameUtils.getFullPath(saveFile.toString()),
                            FilenameUtils.getBaseName(saveFile.toString()));
                    Desktop.getDesktop().open(new File(saveFile.toString()));
                }
            } else if (e.getSource() == jtfFileTemplate && jtfFileTemplate.getText().equals(template)) {
                jtfFileTemplate.setText("");
            } else if (e.getSource() == this) {
                if (jtfFileTemplate.getText().equals("")) {
                    jtfFileTemplate.setText(template);
                }
            }
        }
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    } catch (Throwable throwable) {
        SwingGUI.handleError(this, throwable);
    }
}

From source file:plugin.notes.gui.JIcon.java

private void buttonMouseClicked(MouseEvent evt) {

    if (evt.getClickCount() >= 2) {
        launchFile();
    }
}

From source file:org.ut.biolab.medsavant.client.plugin.PluginRepositoryDialog.java

public final Component getCenterPanel(List<TreeBrowserEntry> roots) {
    table = new TreeTable(new TreeBrowserModel(roots) {
        @Override/* www .  j  a va2 s . com*/
        public String[] getColumnNames() {
            return new String[] { "Name" };
        }
    });
    table.setSortable(true);
    table.setRespectRenderPreferredHeight(true);

    // configure the TreeTable
    table.setExpandAllAllowed(true);
    table.setShowTreeLines(false);
    table.setSortingEnabled(false);
    table.setRowHeight(18);
    table.setShowGrid(false);
    table.setIntercellSpacing(new Dimension(0, 0));
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    //table.expandAll();
    table.expandFirstLevel();
    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                downloadSelectedItem(true);
            }
        }
    });

    // do not select row when expanding a row.
    table.setSelectRowWhenToggling(false);

    table.getColumnModel().getColumn(0).setPreferredWidth(200);
    //table.getColumnModel().getColumn(1).setPreferredWidth(300);
    //table.getColumnModel().getColumn(2).setPreferredWidth(50);
    //table.getColumnModel().getColumn(3).setPreferredWidth(100);
    //table.getColumnModel().getColumn(4).setPreferredWidth(50);

    table.getColumnModel().getColumn(0).setCellRenderer(FILE_RENDERER);

    // add searchable feature
    TableSearchable searchable = new TableSearchable(table) {

        @Override
        protected String convertElementToString(Object item) {
            if (item instanceof TreeBrowserEntry) {
                return ((TreeBrowserEntry) item).getType();
            }
            return super.convertElementToString(item);
        }
    };
    searchable.setMainIndex(0); // only search for name column

    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.getViewport().setBackground(Color.WHITE);

    JPanel panel = new JPanel(new BorderLayout(6, 6));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.setPreferredSize(new Dimension(800, 500));
    return panel;
}

From source file:AncestorTree.java

public boolean isCellEditable(EventObject evt) {
    if (evt instanceof MouseEvent) {
        MouseEvent mEvt = (MouseEvent) evt;
        if (mEvt.getClickCount() == 1) {
            int row = m_tree.getRowForLocation(mEvt.getX(), mEvt.getY());
            if (row != m_lastRow) {
                m_lastRow = row;//  w  ww .ja  v  a 2  s.c om
                m_lastClick = System.currentTimeMillis();
                return false;
            } else if (System.currentTimeMillis() - m_lastClick > 1000) {
                m_lastRow = -1;
                m_lastClick = 0;
                prepareEditor();
                mEvt.consume();
                return true;
            } else
                return false;
        }
    }
    return false;
}

From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel.java

private void buildUI() {
    editor = new GroovyEditor(new ScriptStepGroovyEditorModel());

    logArea = new JLogList("Groovy Test Log");
    logArea.addLogger(groovyStep.getName() + "#" + hashCode(), true);
    logArea.getLogList().addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() < 2)
                return;

            String value = logArea.getLogList().getSelectedValue().toString();
            if (value == null)
                return;

            editor.selectError(value);/*from  w  w w .  j a va  2 s . co m*/
        }
    });

    logArea.getLogList().getModel().addListDataListener(new ListDataChangeListener() {

        @Override
        public void dataChanged(ListModel model) {
            logInspector.setTitle("Log Output (" + model.getSize() + ")");

        }
    });

    inspectorPanel = JInspectorPanelFactory.build(editor);
    logInspector = inspectorPanel.addInspector(new JComponentInspector<JComponent>(logArea, "Log Output (0)",
            "Groovy Log output for this script", true));
    inspectorPanel.setDefaultDividerLocation(0.8F);
    inspectorPanel.activate(logInspector);
    add(inspectorPanel.getComponent(), BorderLayout.CENTER);
    add(buildToolbar(), BorderLayout.NORTH);
    add(buildStatusBar(), BorderLayout.SOUTH);

    componentEnabler.add(editor);
}

From source file:playground.sergioo.workplaceCapacities2012.gui.ClustersPanel.java

@Override
public void mouseClicked(MouseEvent e) {
    this.requestFocus();
    double[] p = getWorld(e.getX(), e.getY());
    if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON3)
        camera.centerCamera(p);/* w  w  w  .  j a va2 s .  c  o m*/
    else {
        if (window.getOption().equals(Option.ZOOM) && e.getButton() == MouseEvent.BUTTON1)
            camera.zoomIn(p[0], p[1]);
        else if (window.getOption().equals(Option.ZOOM) && e.getButton() == MouseEvent.BUTTON3)
            camera.zoomOut(p[0], p[1]);
    }
    repaint();
}

From source file:latexstudio.editor.DropboxRevisionsTopComponent.java

private void jTable1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MousePressed
    if (evt.getClickCount() == 2) {
        // Resolving which row has been double-clicked
        Point point = evt.getPoint();
        JTable table = (JTable) evt.getSource();
        int row = table.rowAtPoint(point);
        // Finding revision using information from the clicked row
        Object revisionNumber = table.getValueAt(row, REVISION_COLUMN);
        if (revisionNumber != null) {
            loadRevision(revisionNumber.toString());
        }/*  w  w  w .  jav  a  2s . c  o m*/
    }
}

From source file:se.trixon.jota.client.ui.editor.JobsPanel.java

private void listMouseClicked(java.awt.event.MouseEvent evt) {
    if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) {
        editButtonActionPerformed(null);
    }//w w w. ja va 2  s.  c  o  m
}