List of usage examples for java.awt.event MouseEvent getClickCount
public int getClickCount()
From source file:edu.ku.brc.ui.dnd.SimpleGlassPane.java
@Override protected void processMouseEvent(MouseEvent e) { if (hideOnClick && e.getClickCount() == 1) { hideOnClick = false;// ww w .j a v a 2 s. c om SwingUtilities.invokeLater(new Runnable() { @Override public void run() { SimpleGlassPane.this.setVisible(false); } }); } else if (!dblClickProgBar || !getProgressBarRect().contains(e.getPoint())) { e.consume(); } super.processMouseEvent(e); }
From source file:org.alex73.skarynka.scan.ui.book.BooksController.java
public BooksController() { try {/*from ww w . jav a 2s .com*/ panel = new BooksPanel(); ((AbstractDocument) panel.txtNewName.getDocument()).setDocumentFilter(bookNameFilter); listScanDirs(); panel.table.setModel(model()); panel.table.setRowSelectionAllowed(true); panel.table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { BookRow b = books.get(panel.table.getSelectedRow()); DataStorage.openBook(b.bookName, true); } } @Override public void mousePressed(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { for (int i = 0; i < panel.menuProcess.getComponentCount(); i++) { Component item = panel.menuProcess.getComponent(i); if ((item instanceof JMenuItem) && (item.getName() != null)) { panel.menuProcess.remove(i); i--; } } if (Context.getPermissions().BookControl) { for (int scale : new int[] { 25, 50, 75, 100, 200 }) { JMenuItem item = new JMenuItem(scale + "%"); item.setName(scale + "%"); item.addActionListener(new ChangeScale(scale)); panel.menuProcess.add(item); } } currentBooksNames.clear(); int[] selected = panel.table.getSelectedRows(); boolean allLocals = true; boolean processAllowed = Context.getPermissions().BookControl; for (int row : selected) { BookRow b = books.get(panel.table.convertRowIndexToModel(row)); currentBooksNames.add(b.bookName); if (!b.local) { allLocals = false; } } panel.itemFinish.setVisible(allLocals); if (processAllowed) { for (Map.Entry<String, String> en : Context.getProcessCommands().entrySet()) { JMenuItem item = new JMenuItem(en.getValue()); item.setName(en.getKey()); item.addActionListener(commandListener); panel.menuProcess.add(item); } } panel.menuProcess.show(panel.table, e.getX(), e.getY()); } } }); panel.btnCreate.setEnabled(false); panel.btnCreate.addActionListener( new ActionErrorListener(panel, "ERROR_BOOK_CREATE", LOG, "Error create book") { protected void action(ActionEvent e) throws Exception { File bookDir = new File(Context.getBookDir(), panel.txtNewName.getText()); if (bookDir.exists()) { JOptionPane.showMessageDialog(panel, Messages.getString("PANEL_BOOK_NEW_BOOK_EXIST"), Messages.getString("PANEL_BOOK_TITLE"), JOptionPane.WARNING_MESSAGE); return; } DataStorage.openBook(panel.txtNewName.getText(), true); } }); setMenuListeners(); } catch (Throwable ex) { LOG.error("Error list books", ex); JOptionPane.showMessageDialog(DataStorage.mainFrame, "Error: " + ex.getClass() + " / " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.preenchedor_formulario.PanelPreenchedorFormulario.java
public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { int row = this.tabelaDeErros.getSelectedRow(); if (row == -1) return; int linhaToGo = Integer.parseInt(tabelaDeErros.getValueAt(row, 0).toString()); if (linhaToGo == 0) return; textAreaSourceCode.goToLine(linhaToGo); textAreaSourceCode.selectLine(linhaToGo); erroAtual = row;/* ww w . ja va 2 s. c o m*/ btnAplicar.setEnabled(true); } }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaToolsDlg.java
@Override public void createUI() { setOkLabel(getResourceString("CLOSE")); super.createUI(); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); Vector<DisplayLocale> localeDisplays = new Vector<DisplayLocale>(); for (Locale locale : SchemaLocalizerDlg.getLocalesInUseInDB(schemaType)) { localeDisplays.add(new DisplayLocale(locale)); }/*ww w .j a v a2 s .c o m*/ localeList = new JList(localeDisplays); JScrollPane sp = UIHelper.createScrollPane(localeList, true); CellConstraints cc = new CellConstraints(); PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p,2px,p,16px,p,4px,p,8px,p,10px")); builder.addSeparator(getResourceString("SL_LOCALES_IN_USE"), cc.xywh(1, 1, 3, 1)); builder.add(sp, cc.xywh(1, 3, 3, 1)); builder.addSeparator(getResourceString("SL_TASKS"), cc.xywh(1, 5, 3, 1)); builder.add(editSchemaBtn, cc.xy(1, 7)); builder.add(removeLocaleBtn, cc.xy(3, 7)); builder.add(exportSchemaLocBtn, cc.xy(1, 9)); builder.add(importSchemaLocBtn, cc.xy(3, 9)); builder.setDefaultDialogBorder(); contentPanel = builder.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); enableBtns(false); localeList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { localeSelected(); } }); localeList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { editSchema(); } } }); editSchemaBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { editSchema(); } }); removeLocaleBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { removeSchemaLocale(); } }); exportSchemaLocBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { exportSchemaLocales(); } }); importSchemaLocBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { chooseImportType(); } }); pack(); }
From source file:jgnash.ui.report.compiled.IncomeExpensePieChart.java
private JPanel createPanel() { EnumSet<AccountType> set = EnumSet.of(AccountType.INCOME, AccountType.EXPENSE); JButton refreshButton = new JButton(rb.getString("Button.Refresh")); startField = new DatePanel(); endField = new DatePanel(); showEmptyCheck = new JCheckBox(rb.getString("Label.ShowEmptyAccounts")); showPercentCheck = new JCheckBox(rb.getString("Button.ShowPercentValues")); final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT); Objects.requireNonNull(engine); combo = AccountListComboBox.getParentTypeInstance(engine.getRootAccount(), set); final LocalDate dStart = DateUtils.getFirstDayOfTheMonth(LocalDate.now()).minusYears(1); long start = pref.getLong(START_DATE, DateUtils.asEpochMilli(dStart)); startField.setDate(DateUtils.asLocalDate(start)); currentAccount = combo.getSelectedAccount(); JFreeChart chart = createPieChart(currentAccount); chartPanel = new ChartPanel(chart, true, true, true, false, true); // (chart, properties, save, print, zoom, tooltips) FormLayout layout = new FormLayout("p, 4dlu, 70dlu, 8dlu, p, 4dlu, 70dlu, 8dlu, p, 4dlu:g, left:p", "f:d, 3dlu, f:d, 6dlu, f:p:g"); DefaultFormBuilder builder = new DefaultFormBuilder(layout); layout.setRowGroups(new int[][] { { 1, 3 } }); builder.append(combo, 9);//from w w w . j a v a2s . c om builder.append(showEmptyCheck); builder.nextLine(); builder.nextLine(); builder.append(rb.getString("Label.StartDate"), startField); builder.append(rb.getString("Label.EndDate"), endField); builder.append(refreshButton); builder.append(showPercentCheck); builder.nextLine(); builder.nextLine(); builder.append(chartPanel, 11); JPanel panel = builder.getPanel(); combo.addActionListener(e -> { setCurrentAccount(combo.getSelectedAccount()); pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate())); }); refreshButton.addActionListener(e -> { setCurrentAccount(currentAccount); pref.putLong(START_DATE, DateUtils.asEpochMilli(startField.getLocalDate())); }); showEmptyCheck.addActionListener(e -> setCurrentAccount(currentAccount)); showPercentCheck.addActionListener(e -> ((PiePlot) chartPanel.getChart().getPlot()) .setLabelGenerator(showPercentCheck.isSelected() ? percentLabels : defaultLabels)); ChartMouseListener mouseListener = new ChartMouseListener() { @Override public void chartMouseClicked(final ChartMouseEvent event) { MouseEvent me = event.getTrigger(); if (me.getID() == MouseEvent.MOUSE_CLICKED && me.getClickCount() == 1) { try { ChartEntity entity = event.getEntity(); // expand sections if interesting, back out if in nothing if (entity instanceof PieSectionEntity) { Account a = (Account) ((PieSectionEntity) entity).getSectionKey(); if (a.getChildCount() > 0) { setCurrentAccount(a); } } else if (entity == null) { Account parent = currentAccount; if (parent == null) { return; } parent = parent.getParent(); if (parent == null || parent instanceof RootAccount) { return; } setCurrentAccount(parent); } } catch (final Exception e) { Logger.getLogger(IncomeExpensePieChart.class.getName()).log(Level.SEVERE, e.getLocalizedMessage(), e); } } } @Override public void chartMouseMoved(ChartMouseEvent event) { setChartCursor(chartPanel, event.getEntity(), event.getTrigger().getPoint()); } }; chartPanel.addChartMouseListener(mouseListener); return panel; }
From source file:io.github.jeremgamer.editor.panels.Panels.java
public Panels(final JFrame frame, final PanelsPanel pp) { this.setBorder(BorderFactory.createTitledBorder("")); JButton add = null;/* w w w .j a va 2 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(panelList), "Nommez le panneau :", "Crer un panneau", 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 PanelSave(name); PanelsPanel.updateLists(); mainPanel.addItem(name); } } 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 (panelList.getSelectedValue() != null) { File file = new File("projects/" + Editor.getProjectName() + "/panels/" + panelList.getSelectedValue() + "/" + panelList.getSelectedValue() + ".rbd"); JOptionPane jop = new JOptionPane(); @SuppressWarnings("static-access") int option = jop.showConfirmDialog((JFrame) SwingUtilities.windowForComponent(panelList), "tes-vous sr de vouloir supprimer ce panneau?", "Avertissement", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { if (panelList.getSelectedValue().equals(pp.getFileName())) { pp.setFileName(""); } pp.hide(); file.delete(); File parent = new File(file.getParent()); for (File img : FileUtils.listFiles(parent, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { img.delete(); } parent.delete(); mainPanel.removeItem(panelList.getSelectedValue()); data.remove(panelList.getSelectedIndex()); ActionPanel.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); mainPanel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); GeneralSave gs = new GeneralSave(); try { gs.load(new File("projects/" + Editor.getProjectName() + "/general.rbd")); gs.set("mainPanel", combo.getSelectedItem()); } catch (IOException e) { e.printStackTrace(); } } }); updateList(); panelList.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) { pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); pp.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { pp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { pp.hideThenShow(); previousSelection = list.getSelectedValue(); pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); } } catch (NullPointerException npe) { pp.hide(); list.clearSelection(); } } } else if (evt.getClickCount() == 3) { int index = list.locationToIndex(evt.getPoint()); if (isOpen == false) { pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); pp.show(); previousSelection = list.getSelectedValue(); isOpen = true; } else { try { if (previousSelection.equals(list.getModel().getElementAt(index))) { pp.hide(); previousSelection = list.getSelectedValue(); list.clearSelection(); isOpen = false; } else { pp.hideThenShow(); previousSelection = list.getSelectedValue(); pp.load(new File("projects/" + Editor.getProjectName() + "/panels/" + list.getModel().getElementAt(index) + "/" + list.getModel().getElementAt(index) + ".rbd")); PanelsPanel.updateLists(); } } catch (NullPointerException npe) { pp.hide(); list.clearSelection(); } } } } }); JScrollPane listPane = new JScrollPane(panelList); listPane.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(buttons); this.add(listPane); JPanel mainPanelInput = new JPanel(); mainPanelInput.setPreferredSize(new Dimension(280, 35)); mainPanelInput.setMaximumSize(new Dimension(280, 35)); mainPanelInput.add(new JLabel("Panneau principal:")); mainPanel.setPreferredSize(new Dimension(150, 27)); mainPanelInput.add(mainPanel); this.add(mainPanelInput); }
From source file:ucar.unidata.idv.control.chart.ScatterPlotChartWrapper.java
/** * Handle the event//from www . j av a2 s. co m * * @param event the event * * @return Should we pass on this event */ public boolean chartPanelMouseClicked(MouseEvent event) { if (SwingUtilities.isRightMouseButton(event) || (event.getClickCount() < 2)) { return super.chartPanelMousePressed(event); } List series = ((MyScatterPlot) plot).getSeries(); //TODO: Check if click is inside data area double minDistance = 100; int minIdx = -1; double minTime = -1; for (int seriesIdx = 0; seriesIdx < series.size(); seriesIdx++) { NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(seriesIdx); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(seriesIdx); double[][] data = (double[][]) series.get(seriesIdx); for (int i = 0; i < data[0].length; i++) { double x = domainAxis.valueToJava2D(data[0][i], getChartPanel().getScreenDataArea(), plot.getDomainAxisEdge()); double y = rangeAxis.valueToJava2D(data[1][i], getChartPanel().getScreenDataArea(), plot.getRangeAxisEdge()); double distance = Math .sqrt((x - event.getX()) * (x - event.getX()) + (y - event.getY()) * (y - event.getY())); if (distance < minDistance) { minDistance = distance; minIdx = i; } } if (minIdx >= 0) { minTime = timeValues1[minIdx]; } } if (minIdx < 0) { return EVENT_PASSON; } firePropertyChange(PROP_SELECTEDTIME, null, new Double(minTime)); return EVENT_PASSON; }
From source file:labr_client.GUI.forms.EhealthSearch.java
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked // TODO add your handling code here: if (evt.getClickCount() == 2) { JTable target = (JTable) evt.getSource(); String id = (String) target.getValueAt(target.getSelectedRow(), 2); // setInfo(); }// ww w. j a v a 2 s.c o m }
From source file:org.drugis.addis.gui.builder.NetworkMetaAnalysisView.java
private MouseAdapter treatmentCategorizationListener(final NetworkRelativeEffectTableCellRenderer renderer) { return new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { JTable table = (JTable) e.getComponent(); int row = table.convertRowIndexToModel(table.rowAtPoint(e.getPoint())); int col = table.convertColumnIndexToModel(table.columnAtPoint(e.getPoint())); if (col == row) { Treatment treatment = renderer.getTreatment(table.getModel(), col); TreatmentDefinition treatmentDefinition = d_pm.getTreatmentDefinition(treatment); Category category = treatmentDefinition.getContents().first(); if (category != null && !category.isTrivial()) { d_mainWindow.leftTreeFocus(category.getCategorization()); }/*ww w.j a v a 2 s .c o m*/ } } } }; }
From source file:uk.ac.ebi.pride.tools.converter.gui.dialogs.SimplePTMDialog.java
private void ptmListMouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { if (ptmList.getSelectedValue() != null) { validatePTM((String) ptmList.getSelectedValue()); }//w w w . j a v a 2s.c om } }