List of usage examples for java.awt.event MouseEvent getClickCount
public int getClickCount()
From source file:ro.nextreports.designer.querybuilder.SelectionColumnPanel.java
private void addDoubleClick() { columnList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { onDoubleClick();/*w ww .j a va 2 s .co m*/ } } }); }
From source file:savant.agp.HTTPBrowser.java
public HTTPBrowser(URL rootURL) throws IOException { host = rootURL.getHost();//from ww w .j av a2 s . co m int p = rootURL.getPort(); port = p != -1 ? p : rootURL.getDefaultPort(); rootDir = new File(rootURL.getPath()); curDir = rootDir; setLayout(new BorderLayout()); addressLabel = new JLabel(); add(addressLabel, BorderLayout.NORTH); add(getToolBar(), BorderLayout.SOUTH); table = new JTable(); updateDirectory(); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { String f = ((HTTPTableModel) table.getModel()).getEntry(table.rowAtPoint(evt.getPoint())); if (f.equals("..")) { // Going up a directory. curDir = curDir.getParentFile(); updateDirectory(); } else if (!f.contains(".")) { if (f.startsWith("/")) { curDir = new File(f); } else { curDir = new File(curDir, f); } updateDirectory(); } else { openIndexAs(table.rowAtPoint(evt.getPoint()), OpenAsOption.TRACK); } } } }); JScrollPane scrollPane = new JScrollPane(table); scrollPane.getViewport().setBackground(Color.WHITE); scrollPane.setPreferredSize(new Dimension(800, 500)); add(scrollPane, BorderLayout.CENTER); this.setPreferredSize(new Dimension(800, 500)); }
From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java
private void initLabelLink(JLabel label, final String url) { label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); label.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent event) { if (event.getClickCount() > 0) { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); try { URI uri = new URI(url); desktop.browse(uri); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); }//from w ww. j av a 2s . c o m } } } }); }
From source file:org.nuclos.client.genericobject.logbook.LogbookController.java
private void setupDoubleClickListener(final LogbookPanel pnlLogbook) { pnlLogbook.getTable().addMouseListener(new MouseAdapter() { @Override//from www .ja va2 s.co m public void mouseClicked(MouseEvent ev) { if (ev.getClickCount() == 2) { final int iSelectedRow = pnlLogbook.getTable().getSelectedRow(); if (iSelectedRow >= 0) { final int modelRow = pnlLogbook.getTable().convertRowIndexToModel(iSelectedRow); final LogbookVO logbookvoSelected = pnlLogbook.getLogbookTableModel().getRow(modelRow); final Date dateHistoric = logbookvoSelected.getChangedAt(); cmdShowHistoricalGenericObject(getFrame(), dateHistoric); } } } }); }
From source file:net.sourceforge.entrainer.jfreechart.UnitChart.java
private void init() { chart = new JFreeChart(getXYPlot()); chartPanel = new ChartPanel(chart); chartPanel.addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(ChartMouseEvent event) { }/* w w w. j a va 2s . com*/ public void chartMouseMoved(ChartMouseEvent event) { if (event.getEntity() != null && (currentEntity == null || !currentEntity.equals(event.getEntity()))) { if (event.getEntity() instanceof XYItemEntity) { showPopup((XYItemEntity) event.getEntity()); } } else if (event.getEntity() == null && timer != null) { timer.dismiss(); timer = null; currentEntity = null; } } }); getContentPane().add(chartPanel); addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.isControlDown() && e.getClickCount() == 1) { openBrowser(getLocalDocAddress()); } } }); }
From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java
@Override public void mouseClicked(MouseEvent event) { super.mouseClicked(event); if (SwingUtilities.isLeftMouseButton(event) && event.getClickCount() == 2) { final JFreeChart chartToExplain = getChart(); if (chartToExplain.getPlot() instanceof PiePlot) { return; }/*from w w w. j a v a 2 s . c o m*/ DBSeerXYLineAndShapeRenderer renderer = (DBSeerXYLineAndShapeRenderer) chartToExplain.getXYPlot() .getRenderer(); renderer.setLastSeriesAndCategory(-1, -1); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { DBSeerPlotExplainFrame newFrame = new DBSeerPlotExplainFrame( (JFreeChart) chartToExplain.clone()); // newFrame.setPreferredSize(new Dimension(1280,800)); newFrame.pack(); newFrame.setLocationRelativeTo(DBSeerGUI.mainFrame); newFrame.setVisible(true); } catch (CloneNotSupportedException e) { JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } }); } }
From source file:io.github.jeremgamer.editor.panels.Labels.java
public Labels(final JFrame frame, final LabelPanel lp, final PanelSave ps) { this.frame = frame; this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;//from www. jav a2 s .c o m try { add = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); } catch (IOException e) { e.printStackTrace(); } add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") String name = jop.showInputDialog((JFrame) SwingUtilities.windowForComponent(labelList), "Nommez le label :", "Crer un label", JOptionPane.QUESTION_MESSAGE); if (name != null) { for (int i = 0; i < data.getSize(); i++) { if (data.get(i).equals(name)) { name += "1"; } } data.addElement(name); new LabelSave(name); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } catch (IOException e) { e.printStackTrace(); } } }); JButton remove = null; try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (labelList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/labels/" + labelList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(labelList), "tes-vous sr de vouloir supprimer ce label?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { File dir = new File("projects/" + Editor.getProjectName() + "/panels"); for (File f : FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { if (!f.isDirectory()) { try { ps.load(f); } catch (IOException e) { e.printStackTrace(); } for (String section : ps .getSectionsContaining(labelList.getSelectedValue() + " (Label)")) { ps.removeSection(section); try { ps.save(f); } catch (IOException e) { e.printStackTrace(); } } } } if (labelList.getSelectedValue().equals(lp.getFileName())) { lp.setFileName(""); } lp.hide(); file.delete(); data.remove(labelList.getSelectedIndex()); ActionPanel.updateLists(); OtherPanel.updateLists(); PanelsPanel.updateLists(); } } } catch (NullPointerException npe) { npe.printStackTrace(); } } }); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); buttons.add(add); buttons.add(remove); updateList(); labelList.addMouseListener(new MouseAdapter() { @SuppressWarnings("unchecked") public void mouseClicked(MouseEvent evt) { JList<String> list = (JList<String>) evt.getSource(); if (evt.getClickCount() == 2) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { lp.show(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { lp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { lp.hideThenShow(); previousSelection = list.getSelectedValue(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { lp.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { lp.show(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { lp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { lp.hideThenShow(); previousSelection = list.getSelectedValue(); lp.load(new File("projects/" + Editor.getProjectName() + "/labels/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { lp.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(labelList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); }
From source file:com.limegroup.gnutella.gui.tables.ActionIconAndNameEditor.java
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row, int column) { ActionIconAndNameHolder in = (ActionIconAndNameHolder) value; action = in.getAction();/*from ww w . j a v a 2 s . co m*/ final Component component = new ActionIconAndNameRenderer().getTableCellRendererComponent(table, value, isSelected, true, row, column); component.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (actionRegion == null) { component_mousePressed(e); } else { if (actionRegion.contains(e.getPoint())) { component_mousePressed(e); } else { if (e.getClickCount() >= 2) { Toolkit.getDefaultToolkit().getSystemEventQueue() .postEvent(new MouseEvent(table, MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), component.getX() + e.getX(), component.getY() + e.getY(), e.getClickCount(), false)); } } } } else if (e.getButton() == MouseEvent.BUTTON3) { Toolkit.getDefaultToolkit().getSystemEventQueue() .postEvent(new MouseEvent(table, e.getID(), e.getWhen(), e.getModifiers(), component.getX() + e.getX(), component.getY() + e.getY(), e.getClickCount(), true)); } } }); return component; }
From source file:net.sf.mzmine.modules.visualization.ida.IDAPlot.java
@Override public void mouseClicked(final MouseEvent event) { // Let the parent handle the event (selection etc.) super.mouseClicked(event); if (event.getX() < 70) { // User clicked on Y-axis if (event.getClickCount() == 2) { // Reset zoom on Y-axis XYDataset data = ((XYPlot) getChart().getPlot()).getDataset(); Number maximum = DatasetUtilities.findMaximumRangeValue(data); getXYPlot().getRangeAxis().setRange(0, 1.05 * maximum.floatValue()); } else if (event.getClickCount() == 1) { // Auto range on Y-axis getXYPlot().getRangeAxis().setAutoTickUnitSelection(true); getXYPlot().getRangeAxis().setAutoRange(true); }/* w ww . j ava 2 s . com*/ } else if (event.getY() > this.getChartRenderingInfo().getPlotInfo().getPlotArea().getMaxY() - 41 && event.getClickCount() == 2) { // Reset zoom on X-axis getXYPlot().getDomainAxis().setAutoTickUnitSelection(true); restoreAutoDomainBounds(); } else if (event.getClickCount() == 2) { visualizer.actionPerformed( new ActionEvent(event.getSource(), ActionEvent.ACTION_PERFORMED, "SHOW_SPECTRUM")); } }
From source file:net.sf.mzmine.modules.visualization.msms.MsMsPlot.java
@Override public void mouseClicked(final MouseEvent event) { // Let the parent handle the event (selection etc.) super.mouseClicked(event); if (event.getX() < 70) { // User clicked on Y-axis if (event.getClickCount() == 2) { // Reset zoom on Y-axis XYDataset data = ((XYPlot) getChart().getPlot()).getDataset(); Number maximum = DatasetUtils.findMaximumRangeValue(data); getXYPlot().getRangeAxis().setRange(0, 1.05 * maximum.floatValue()); } else if (event.getClickCount() == 1) { // Auto range on Y-axis getXYPlot().getRangeAxis().setAutoTickUnitSelection(true); getXYPlot().getRangeAxis().setAutoRange(true); }/*from www . j av a2 s .c o m*/ } else if (event.getY() > this.getChartRenderingInfo().getPlotInfo().getPlotArea().getMaxY() - 41 && event.getClickCount() == 2) { // Reset zoom on X-axis getXYPlot().getDomainAxis().setAutoTickUnitSelection(true); restoreAutoDomainBounds(); } else if (event.getClickCount() == 2) { visualizer.actionPerformed( new ActionEvent(event.getSource(), ActionEvent.ACTION_PERFORMED, "SHOW_SPECTRUM")); } }