List of usage examples for java.awt.event MouseEvent getClickCount
public int getClickCount()
From source file:com.github.alexfalappa.nbspringboot.projects.customizer.CfgPropsDialog.java
private void lCfgPropsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lCfgPropsMouseClicked if (evt.getButton() == BUTTON1 && evt.getClickCount() > 1) { bOkActionPerformed(null);//from ww w . j ava 2 s . c o m } }
From source file:savant.view.variation.swing.VariationModule.java
public VariationModule(VariationController vc) { super(new GridBagLayout()); controller = vc;/*from w w w .ja v a 2s . co m*/ // Toolbar shared by all panels. JToolBar tools = new JToolBar(); tools.setFloatable(false); rangeField = new JTextField(); rangeField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { String text = rangeField.getText(); try { Bookmark bm = new Bookmark(text, controller.getReference(), controller.getVisibleRange()); controller.setLocation(bm.getReference(), (Range) bm.getRange()); } catch (ParseException x) { DialogUtils.displayMessage(String.format("Unable to parse \"%s\" as a location.", text)); } } }); tools.add(rangeField); tools.addSeparator(); JButton zoomInButton = new JButton(); zoomInButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMIN)); zoomInButton.setBorderPainted(false); zoomInButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controller.zoomIn(); } }); tools.add(zoomInButton); JButton zoomOutButton = new JButton(); zoomOutButton.setIcon(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.ZOOMOUT)); zoomOutButton.setBorderPainted(false); zoomOutButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { controller.zoomOut(); } }); tools.add(zoomOutButton); tools.addSeparator(); JButton controlsButton = new JButton("Controls"); controlsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (controller.getTracks().length > 0) { new CaseControlDialog(controller).setVisible(true); frequencyPlot.repaint(); } else { Toolkit.getDefaultToolkit().beep(); } } }); tools.add(controlsButton); tabs = new JTabbedPane(); table = new RecordTable(new VariantTableModel(null)); table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { controller.navigateToRecord(controller.getData().get(table.getSelectedRow())); } } }); tabs.addTab("Table", new JScrollPane(table)); map = new VariantMap(controller); map.addMouseWheelListener(wheelListener); LocationController.getInstance().addListener(new Listener<LocationChangedEvent>() { @Override public void handleEvent(LocationChangedEvent event) { map.repaint(); } }); JPanel mapPanel = populatePanel(map); tabs.addTab("Map", mapPanel); frequencyPlot = new AlleleFrequencyPlot(controller); frequencyPlot.addMouseWheelListener(wheelListener); JPanel frequencyPanel = populatePanel(frequencyPlot); tabs.addTab("Allele Frequency", frequencyPanel); JPanel ldPanel = new JPanel(); ldPanel.setLayout(new GridBagLayout()); ActionListener redrawForcer = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { ldPlot.repaint(); } }; JRadioButton dPrimeButton = new JRadioButton("D\u2032", true); dPrimeButton.setActionCommand("true"); dPrimeButton.addActionListener(redrawForcer); JRadioButton rSquaredButton = new JRadioButton("r\u00B2", false); rSquaredButton.setActionCommand("false"); rSquaredButton.addActionListener(redrawForcer); methodGroup = new ButtonGroup(); JPanel methodPanel = new JPanel(); methodPanel.setBorder(BorderFactory.createTitledBorder("Calculation Method")); methodPanel.add(dPrimeButton); methodGroup.add(dPrimeButton); methodPanel.add(rSquaredButton); methodGroup.add(rSquaredButton); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; gbc.weighty = 0.0; ldPanel.add(methodPanel, gbc); ldPlot = new LDPlot(controller); JPanel lowerLDPanel = populatePanel(ldPlot); gbc.weighty = 1.0; ldPanel.add(lowerLDPanel, gbc); tabs.addTab("LD Plot", ldPanel); gbc.weighty = 0.0; add(tools, gbc); // Create the informative cards, but don't use them. messageLabel = new JLabel(); messageLabel.setFont(MESSAGE_FONT); messagePanel = populatePanel(messageLabel); progressPanel = new ProgressPanel(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { controller.cancelDataRequests(); } }); showCard(tabs, null); }
From source file:org.zaproxy.zap.extension.ascan.PolicyManagerDialog.java
private JTable getParamsTable() { if (paramsTable == null) { paramsTable = new JTable(); paramsTable.setModel(getParamsModel()); paramsTable.addMouseListener(new MouseListener() { @Override//from www . jav a 2s . co m public void mouseClicked(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { if (e.getClickCount() >= 2) { int row = paramsTable.rowAtPoint(e.getPoint()); if (row >= 0) { String name = (String) getParamsModel().getValueAt(row, 0); if (name != null) { try { extension.showPolicyDialog(PolicyManagerDialog.this, name); } catch (ConfigurationException e1) { logger.error(e1.getMessage(), e1); } } } } } @Override public void mouseReleased(MouseEvent e) { } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } }); paramsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (getParamsTable().getSelectedRowCount() == 0) { getModifyButton().setEnabled(false); getRemoveButton().setEnabled(false); getExportButton().setEnabled(false); } else if (getParamsTable().getSelectedRowCount() == 1) { getModifyButton().setEnabled(true); // Dont let the last policy be removed getRemoveButton().setEnabled(getParamsModel().getRowCount() > 1); getExportButton().setEnabled(true); } else { getModifyButton().setEnabled(false); getRemoveButton().setEnabled(false); getExportButton().setEnabled(false); } } }); } return paramsTable; }
From source file:org.sonarlint.intellij.config.global.SonarQubeServerMgmtPanel.java
public void create() { Application app = ApplicationManager.getApplication(); serverManager = app.getComponent(SonarLintServerManager.class); serverChangeListener = app.getMessageBus() .syncPublisher(GlobalConfigurationListener.SONARLINT_GLOBAL_CONFIG_TOPIC); serverList = new JBList(); serverList.getEmptyText().setText(LABEL_NO_SERVERS); serverList.addMouseListener(new MouseAdapter() { @Override/* w w w . j a v a 2 s .com*/ public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { editServer(); } } }); serverList.addListSelectionListener(e -> { if (!e.getValueIsAdjusting()) { onServerSelect(); } }); serversPanel = new JPanel(new BorderLayout()); ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(serverList).setEditActionName("Edit") .setEditAction(e -> editServer()).disableUpDownActions(); toolbarDecorator.setAddAction(new AddServerAction()); toolbarDecorator.setRemoveAction(new RemoveServerAction()); serversPanel.add(toolbarDecorator.createPanel(), BorderLayout.CENTER); splitter = new Splitter(true); splitter.setFirstComponent(serversPanel); splitter.setSecondComponent(createServerStatus()); JBLabel emptyLabel = new JBLabel("No server selected", SwingConstants.CENTER); emptyPanel = new JPanel(new BorderLayout()); emptyPanel.add(emptyLabel, BorderLayout.CENTER); Border b = IdeBorderFactory.createTitledBorder("SonarQube servers"); panel = new JPanel(new BorderLayout()); panel.setBorder(b); panel.add(splitter); serverList.setCellRenderer(new ColoredListCellRenderer() { @Override protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { SonarQubeServer server = (SonarQubeServer) value; try { setIcon(ResourceLoader.getIcon(LIST_ICON)); } catch (IOException e) { LOGGER.error("Error loading SonarLint icon", e); } append(server.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); } }); }
From source file:de.codesourcery.eve.skills.ui.components.impl.ItemChooserComponent.java
@Override protected JPanel createPanelHook() { tree.setRootVisible(false);/* w ww . j a v a 2 s. c o m*/ tree.setCellRenderer(treeRenderer); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() != 2 || e.isPopupTrigger()) { return; } final TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY()); final ITreeNode node = (ITreeNode) path.getLastPathComponent(); if (node.getValue() instanceof InventoryType) { final InventoryType selectedItem = (InventoryType) node.getValue(); selectedItemsModel.addItem(selectedItem); if (selectionMode == SelectionMode.SINGLE_SELECTION) { okButtonClicked(); } else if (selectionMode == SelectionMode.MULTIPLE_SELECTION) { // ok } else { throw new RuntimeException("Unhandled mode " + selectionMode); } } } }); tree.addTreeWillExpandListener(new TreeWillExpandListener() { @Override public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { } @Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { handleTreeExpansion(event); } }); final JScrollPane pane = new JScrollPane(tree); pane.setPreferredSize(new Dimension(400, 400)); final JPanel result = new JPanel(); result.setLayout(new GridBagLayout()); switch (selectionMode) { case SINGLE_SELECTION: result.add(pane, constraints().useRemainingSpace().resizeBoth().end()); break; case MULTIPLE_SELECTION: result.add(pane, constraints(0, 0).useRelativeWidth().resizeBoth().end()); result.add(createListViewPanel(), constraints(1, 0).useRemainingWidth().resizeBoth().end()); break; default: throw new RuntimeException("Unhandled selection mode" + selectionMode); } return result; }
From source file:org.kontalk.view.UserListView.java
UserListView(final View view, UserList userList) { super();/*from www . j av a 2 s . c o m*/ mView = view; mUserList = userList; this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //this.setDragEnabled(true); // right click popup menu mPopupMenu = new UserPopupMenu(); // actions triggered by mouse events this.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { mView.selectThreadByUser(UserListView.this.getSelectedValue()); } } @Override public void mousePressed(MouseEvent e) { check(e); } @Override public void mouseReleased(MouseEvent e) { check(e); } private void check(MouseEvent e) { if (e.isPopupTrigger()) { int row = UserListView.this.rowAtPoint(e.getPoint()); UserListView.this.setSelectedItem(row); UserListView.this.showPopupMenu(e); } } }); this.updateOnEDT(null); }
From source file:gtu._work.ui.JarFinderUI.java
private void jList1MouseClicked(MouseEvent evt) { if (evt.getClickCount() != 2) { return;/*from ww w . j ava 2 s . c o m*/ } try { JList list = (JList) evt.getSource(); StringBuilder sb = new StringBuilder("''jar\r\n'?'\r\n"); String fileName = (String) list.getSelectedValue(); ClipboardUtil.getInstance().setContents(fileName); int linecount = 0; for (String clz : jarfinder.getMap().get(fileName)) { if (linecount == 10) { sb.append("...?"); break; } sb.append(clz + "\r\n"); linecount++; } ComfirmDialogResult result = JOptionPaneUtil.newInstance().iconInformationMessage() .confirmButtonYesNoCancel().showConfirmDialog(sb, fileName); String jdGuiExe = StringUtils.trimToEmpty(jdGuiText.getText()); if (result == ComfirmDialogResult.YES_OK_OPTION) { if (OsInfoUtil.isWindows()) { RuntimeBatPromptModeUtil.newInstance() .command(String.format("cmd /c call \"%s\" \"%s\"", jdGuiExe, fileName)).apply(); } else { RuntimeBatPromptModeUtil.newInstance() .command(String.format("java -jar \"%s\" \"%s\"", jdGuiExe, fileName)).apply(); } } if (result == ComfirmDialogResult.NO_OPTION) { DesktopUtil.openDir(new File(fileName).getParentFile()); } } catch (Exception ex) { ex.printStackTrace(); // JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(ex.getMessage(), // "error"); JCommonUtil.handleException(ex); } }
From source file:io.github.jeremgamer.editor.panels.Buttons.java
public Buttons(final JFrame frame, final ButtonPanel be, final PanelSave ps) { this.setBorder(BorderFactory.createTitledBorder("")); this.frame = frame; JButton add = null;// w w w . j av 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(null, "Nommez le bouton :", "Crer un bouton", 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 ButtonSave(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 (buttonList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/buttons/" + buttonList.getSelectedValue() + "/" + buttonList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog(null, "tes-vous sr de vouloir supprimer ce bouton?", "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(buttonList.getSelectedValue() + " (Bouton)")) { ps.removeSection(section); try { ps.save(f); } catch (IOException e) { e.printStackTrace(); } } } } if (buttonList.getSelectedValue().equals(be.getFileName())) { be.setFileName(""); } be.hide(); file.delete(); File parent = new File(file.getParent()); for (File img : FileUtils.listFiles(parent, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { img.delete(); } parent.delete(); data.remove(buttonList.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(); buttonList.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) { be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); be.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { be.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { be.hideThenShow(); previousSelection = list.getSelectedValue(); be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { be.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); be.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { be.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { be.hideThenShow(); previousSelection = list.getSelectedValue(); be.load(new File("projects/" + Editor.getProjectName() + "/buttons/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); } } catch (NullPointerException npe) { be.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(buttonList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); }
From source file:com.android.tools.idea.structure.MavenDependencyLookupDialog.java
public MavenDependencyLookupDialog(@NotNull Project project, @Nullable Module module) { super(project, true); myAndroidModule = module != null && AndroidFacet.getInstance(module) != null; myProgressIcon.suspend();// w w w . j a v a 2s . c om mySearchField.setButtonIcon(AllIcons.Actions.Menu_find); mySearchField.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { startSearch(); } }); mySearchTextField = mySearchField.getTextField(); mySearchTextField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (!isValidCoordinateSelected()) { startSearch(); } else { close(OK_EXIT_CODE); } } }); boolean isPreviewVersion = false; if (module != null) { AndroidFacet facet = AndroidFacet.getInstance(module); if (facet != null) { IdeaAndroidProject androidProject = facet.getIdeaAndroidProject(); if (androidProject != null) { ApiVersion minSdkVersion = androidProject.getSelectedVariant().getMergedFlavor() .getMinSdkVersion(); if (minSdkVersion != null) { isPreviewVersion = new AndroidVersion(minSdkVersion.getApiLevel(), minSdkVersion.getCodename()).isPreview(); } } } } RepositoryUrlManager manager = RepositoryUrlManager.get(); for (String libraryId : RepositoryUrlManager.EXTRAS_REPOSITORY.keySet()) { String libraryCoordinate = manager.getLibraryCoordinate(libraryId, null, isPreviewVersion); if (libraryCoordinate != null) { Artifact artifact = Artifact.fromCoordinate(libraryCoordinate, libraryId); if (artifact != null) { myShownItems.add(artifact); } } } myShownItems.addAll(COMMON_LIBRARIES); myResultList.setModel(new CollectionComboBoxModel(myShownItems, null)); myResultList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent listSelectionEvent) { Artifact value = (Artifact) myResultList.getSelectedValue(); if (value != null) { mySearchTextField.setText(value.getCoordinates()); } } }); myResultList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { if (mouseEvent.getClickCount() == 2 && isValidCoordinateSelected()) { close(OK_EXIT_CODE); } } }); init(); }
From source file:ListProperties.java
public void mouseClicked(MouseEvent mouseEvent) { TableColumnModel columnModel = table.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(mouseEvent.getX()); int column = table.convertColumnIndexToModel(viewColumn); if (mouseEvent.getClickCount() == 1 && column != -1) { System.out.println("Sorting ..."); int shiftPressed = (mouseEvent.getModifiers() & InputEvent.SHIFT_MASK); boolean ascending = (shiftPressed == 0); sorter.sortByColumn(column, ascending); }/*from w w w . j a v a 2 s . com*/ }