List of usage examples for java.awt.event MouseEvent getClickCount
public int getClickCount()
From source file:org.executequery.gui.browser.FindAction.java
private JList initSearchResultsList() { final JList list = new JList(); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ListCellRenderer listCellRenderer = getListCellRenderer(); if (listCellRenderer != null) { list.setCellRenderer(listCellRenderer); }/* w ww .j ava 2 s. c o m*/ list.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { listValueSelected((T) list.getSelectedValue()); } } }); list.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_ENTER) { listValueSelected((T) list.getSelectedValue()); } else if (keyCode == KeyEvent.VK_BACK_SPACE) { searchField.requestFocus(); } } }); return list; }
From source file:proyectoftp.controlador.Controlador.java
@Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { if (clienteFtp.esDirectorio(this.vistaPrincipal.getFicheroSeleccionado())) { vistaPrincipal.setDirectorio(clienteFtp.getDirectorioActual()); cargarListaDirectorioPrincipal(); }/*from w w w. ja v a 2 s. c o m*/ } else { if (clienteFtp.esDirectorio(this.vistaPrincipal.getFicheroSeleccionado())) { int numArchivos = 0; FTPFile[] archivos = clienteFtp.listaNombreDatos(); numArchivos = archivos.length; if (numArchivos > 0) { vistaPrincipal.setDirectorio(clienteFtp.getDirectorioActual() + ", " + numArchivos); } else { vistaPrincipal.setDirectorio(clienteFtp.getDirectorioActual()); } vistaPrincipal.setDirectorioActual( "/" + this.vistaPrincipal.getFicheroSeleccionado().replace("{DIR}", "").trim()); try { clienteFtp.getConexion().changeToParentDirectory(); } catch (IOException ex) { Logger.getLogger(Controlador.class.getName()).log(Level.SEVERE, null, ex); } } else { vistaPrincipal.setDirectorio(clienteFtp.getDirectorioActual()); vistaPrincipal.setDirectorioActual("/" + this.vistaPrincipal.getFicheroSeleccionado()); } } }
From source file:savant.thousandgenomes.FTPBrowser.java
public FTPBrowser(URL rootURL) throws IOException { setRoot(rootURL);//w w w . j a va2s . c om setLayout(new BorderLayout()); addressField = new JTextField(); addressField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { setRoot(new URL(addressField.getText())); updateDirectory(); } catch (Exception x) { DialogUtils.displayException("1000 Genomes Plugin", "Unable to change root directory", x); } } }); add(addressField, BorderLayout.NORTH); table = new JTable(); updateDirectory(); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { int row = table.rowAtPoint(evt.getPoint()); try { FTPFile f = ((FTPTableModel) table.getModel()).getEntry(row); if (f == null) { // Going up a directory. curDir = curDir.getParentFile(); updateDirectory(); } else if (f.isDirectory()) { curDir = new File(curDir, f.getName()); updateDirectory(); } else { TrackUtils.createTrack(new URI( "ftp://" + host + new File(curDir, f.getName()).getPath().replace("\\", "/"))); } } catch (Throwable x) { DialogUtils.displayException("FTP Error", "Unable to process FTP request.", x); } } } }); 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:org.interreg.docexplore.management.manage.ManageComponent.java
@SuppressWarnings("serial") public ManageComponent(MainWindow win, final ManageHandler handler, boolean editable, boolean showPages) { super(new BorderLayout()); this.win = win; this.handler = handler; this.bookList = new JList(new CollectionNode(this)); setBorder(BorderFactory.createLineBorder(Color.black, 1)); bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); bookList.setCellRenderer(new ManageCellRenderer()); //tree.setRowHeight(52); add(new JScrollPane(bookList), BorderLayout.CENTER); if (editable) { bookList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { int index = bookList.locationToIndex(e.getPoint()); if (index < 0 || !bookList.getCellBounds(index, index).contains(e.getPoint())) return; handler.bookOpened((Book) bookList.getModel().getElementAt(index)); }// ww w . ja v a2s . c o m } }); this.toolbar = new ManageToolbar(this); add(toolbar, BorderLayout.NORTH); bookList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; int count = bookList.getSelectedIndices().length; toolbar.deleteButton.setEnabled(count > 0); toolbar.editButton.setEnabled(count == 1); // toolbar.processButton.setEnabled(count == 1); toolbar.exportButton.setEnabled(count == 1); } }); } bookList.setBackground(new JPanel().getBackground()); getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DEL"); getActionMap().put("DEL", new AbstractAction() { public void actionPerformed(ActionEvent arg0) { @SuppressWarnings({ "unchecked", "rawtypes" }) Vector<Book> books = new Vector(Arrays.asList(bookList.getSelectedValues())); if (books.size() > 0 && handler.booksDeleted(books)) { ((CollectionNode) bookList.getModel()).reload(); bookList.clearSelection(); bookList.repaint(); } } }); }
From source file:net.andydvorak.intellij.lessc.ui.configurable.LessProfileConfigurableForm.java
public JComponent createOptionsPanel() { lessDirTextField = new TextFieldWithBrowseButtonImpl(project, UIBundle.message("file.chooser.less.title")); lessDirPanel.add(lessDirTextField, GRIDCONSTRAINTS_FILL_ALL); profileMappingTable.addMouseListener(new MouseListener() { @Override/*from ww w.j a va 2s .com*/ public void mouseClicked(MouseEvent mouseEvent) { if (mouseEvent.getClickCount() == 2 && !mouseEvent.isConsumed()) { mouseEvent.consume(); editRow(); } } @Override public void mousePressed(MouseEvent mouseEvent) { } @Override public void mouseReleased(MouseEvent mouseEvent) { } @Override public void mouseEntered(MouseEvent mouseEvent) { } @Override public void mouseExited(MouseEvent mouseEvent) { } }); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(profileMappingTable); decorator.setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { addRow(); } }).setEditAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { editRow(); } }).disableUpDownActions(); cssDirPanel.add(decorator.createPanel(), GRIDCONSTRAINTS_FILL_ALL); resetPromptsButton.setMnemonic('r'); resetPromptsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { lessManager.getState().resetPrompts(); lessProfilesPanel.setPromptButtonsEnabled(false); } }); resetPromptsButton.setEnabled(!lessManager.getState().hasDefaultPromptSettings()); return rootPanel; }
From source file:MouseClickListener.java
public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) { System.out.print("The mouse left button was clicked"); } else if (SwingUtilities.isRightMouseButton(e)) { System.out.print("The mouse right button was clicked"); } else if (SwingUtilities.isMiddleMouseButton(e)) { System.out.print("The mouse middle button was clicked"); }//from w ww. ja va 2 s .c om System.out.print(e.getClickCount() + "time(s)"); int x = e.getX(); int y = e.getY(); System.out.println(" at (" + x + "," + y + ")"); }
From source file:com.floreantpos.bo.ui.explorer.ModifierExplorer.java
public ModifierExplorer() { setLayout(new BorderLayout(5, 5)); currencySymbol = CurrencyUtil.getCurrencySymbol(); tableModel = new ModifierExplorerModel(); table = new JXTable(tableModel); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setDefaultRenderer(Object.class, new CustomCellRenderer()); add(new JScrollPane(table)); createActionButtons();//from w w w . j a v a 2 s .c om add(buildSearchForm(), BorderLayout.NORTH); updateModifierList(); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { doEditSelectedMenuModifier(); } } }); }
From source file:org.adempiere.apps.graph.PerformanceIndicator.java
/************************************************************************** * Mouse Clicked//from w w w. j ava 2 s. co m * @param e mouse event */ public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) fireActionPerformed(e); if (SwingUtilities.isRightMouseButton(e)) popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); }
From source file:fitmon.WorkoutLog.java
private void removeItem(java.awt.event.MouseEvent evt) { if (evt.getClickCount() == 1) { JTable target = (JTable) evt.getSource(); int row = target.getSelectedRow(); int column = target.getSelectedColumn(); String selectedwkt = (String) target.getValueAt(row, 0); //int index = selectedwkt.indexOf("--"); // String foodName = selectedFood.substring(0, index); //int calorie = selectedFood.substring(index+2); if (target.getColumnName(target.getSelectedColumn()).equals("Edit")) { DefaultTableModel model = (DefaultTableModel) tab.getModel(); model.removeRow(row);// w w w . j a v a2 s. co m for (int i = 0; i < wkt.size(); i++) { if (wkt.get(i).getWorkout().equals(selectedwkt)) //&& wkt.get(i).getCal().equals(calorie)) { wkt.remove(i); break; } } } // do some action if appropriate column } // TODO add your handling code here: }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.dialogs.hexeditors.DialogEditSVGImageValue.java
private void panelPreviewMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_panelPreviewMouseClicked if (evt.getClickCount() > 1) { this.buttonLoadActionPerformed(null); }// w w w . j av a 2 s . c o m }