List of usage examples for java.awt.event MouseEvent isPopupTrigger
public boolean isPopupTrigger()
From source file:com.quinsoft.zeidon.objectbrowser.EntitySquare.java
@Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) doPop(e); }
From source file:biz.wolschon.finance.jgnucash.accountProperties.AccountProperties.java
/** * @return a panel to edit the settings of this section *//* w ww .j a v a 2 s. c o m*/ private JPanel getMySettingsPanel() { if (mySettingsPanel == null) { mySettingsPanel = new JPanel(); mySettingsPanel.setLayout(new BorderLayout()); myPropertySheet = new PropertySheetPanel(); myPropertySheet.setToolBarVisible(true); myPropertySheet.setSorting(false); myPropertySheet.setMode(PropertySheetPanel.VIEW_AS_CATEGORIES); myPropertySheet.setDescriptionVisible(true); myPropertySheet.addPropertySheetChangeListener(new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent aEvt) { Object property = aEvt.getSource(); if (property instanceof DefaultProperty) { DefaultProperty prop = (DefaultProperty) property; try { myAccount.setUserDefinedAttribute(prop.getName(), prop.getValue().toString()); } catch (Exception e) { LOGGER.error("error in writing userDefinedAttribute", e); } } } }); myPropertySheet.getTable().addMouseListener(new MouseAdapter() { /** show popup if mouseReleased is a popupTrigger on this platform. * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent) */ @Override public void mouseReleased(final MouseEvent aE) { if (aE.isPopupTrigger()) { JPopupMenu menu = getPropertyPopup(); menu.show(myPropertySheet, aE.getX(), aE.getY()); } super.mouseClicked(aE); } /** show popup if mousePressed is a popupTrigger on this platform. * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent) */ @Override public void mousePressed(final MouseEvent aE) { if (aE.isPopupTrigger()) { JPopupMenu menu = getPropertyPopup(); menu.show(myPropertySheet, aE.getX(), aE.getY()); } super.mouseClicked(aE); } }); // updateCustomAttributesPanel(); // for (ConfigurationSetting setting : getConfigSection().getSettings()) { // MyProperty myProperty = new MyProperty(setting); // myProperty.addPropertyChangeListener(savingPropertyChangeListener); // propertySheet.addProperty(myProperty); // } mySettingsPanel.add(new JLabel("custom attributes:"), BorderLayout.NORTH); mySettingsPanel.add(myPropertySheet, BorderLayout.CENTER); mySettingsPanel.add(getAddCustomAttrPanel(), BorderLayout.SOUTH); // MyPropertyEditorFactory propertyEditorFactory = new MyPropertyEditorFactory(); // propertySheet.setEditorFactory(propertyEditorFactory); // propertySheet.setRendererFactory(propertyEditorFactory); } return mySettingsPanel; }
From source file:com.mirth.connect.connectors.jdbc.DatabaseMetadataDialog.java
private void checkTableNameSelected(java.awt.event.MouseEvent evt) { if (!evt.isPopupTrigger()) { int row = includedMetaDataTable.rowAtPoint(new Point(evt.getX(), evt.getY())); int column = includedMetaDataTable.columnAtPoint(new Point(evt.getX(), evt.getY())); if (row != -1 && column == 0) { String type = (String) includedMetaDataTable.getModel().getValueAt(row, 2); Boolean selected = (Boolean) includedMetaDataTable.getModel().getValueAt(row, 0); if (type.equals(TABLE_TYPE_COLUMN)) { RefreshTableModel model = (RefreshTableModel) includedMetaDataTable.getModel(); boolean nextTableFound = false; int tableLength = model.getRowCount(); int endRow = -1; for (int i = row + 1; !nextTableFound && i != tableLength; i++) { String nextType = (String) includedMetaDataTable.getModel().getValueAt(i, 2); if (nextType.equals(TABLE_TYPE_COLUMN)) { endRow = i;// w w w . j a v a 2 s . c om nextTableFound = true; } else if (i + 1 == tableLength) { endRow = i + 1; } } if (endRow == -1) { return; } for (int i = row + 1; i < endRow; i++) { model.setValueAt(selected, i, 0); } } } } }
From source file:com.yosanai.java.aws.console.panel.InstancesPanel.java
public void showPopup(MouseEvent e) { if (e.isPopupTrigger()) { tblPopup.show(e.getComponent(), e.getX(), e.getY()); } }
From source file:burlov.ultracipher.swing.MainPanel.java
public MainPanel(Translator translator) { editDataPanel = new EditDataPanel(translator); translator.addToComponent(searchField); listPopup.add(getNewEntryAction());/* w ww . j av a2 s . c o m*/ listPopup.add(getDeleteEntryAction()); setLayout(new BorderLayout()); add(splitPane); /* * Suchpanel initialisieren */ JPanel panel = new JPanel(new BorderLayout()); JPanel searchPanel = new JPanel(new BorderLayout()); searchPanel.add(new JLabel(new ImageIcon(getClass().getResource("find.png"))), BorderLayout.WEST); searchPanel.add(searchField, BorderLayout.CENTER); searchField.setToolTipText("Search"); panel.add(searchPanel, BorderLayout.NORTH); panel.add(new JScrollPane(searchResults), BorderLayout.CENTER); splitPane.setLeftComponent(panel); /* * Anzeigepanel initialisieren */ panel = new JPanel(new BorderLayout()); panel.add(editDataPanel, BorderLayout.CENTER); panel.add(new PassGeneratorPanel(), BorderLayout.SOUTH); splitPane.setRightComponent(panel); searchResults.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { showDeletePopup(e); } @Override public void mouseReleased(MouseEvent e) { showDeletePopup(e); } private void showDeletePopup(MouseEvent e) { if (!e.isPopupTrigger()) { return; } int index = searchResults.locationToIndex(e.getPoint()); if (index > -1) { searchResults.setSelectedIndex(index); } listPopup.show(e.getComponent(), e.getX(), e.getY()); } }); searchResults.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { editDataPanel.editData((DataEntry) searchResults.getSelectedValue(), false); } }); searchField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { initResultList(); } @Override public void insertUpdate(DocumentEvent e) { initResultList(); } @Override public void changedUpdate(DocumentEvent e) { initResultList(); } }); editDataPanel.addNameChangeListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { int index = searchResultModel.indexOf(editDataPanel.getData()); if (index >= 0) { searchResultModel.set(index, editDataPanel.getData()); } } @Override public void insertUpdate(DocumentEvent e) { int index = searchResultModel.indexOf(editDataPanel.getData()); if (index >= 0) { searchResultModel.set(index, editDataPanel.getData()); } } @Override public void changedUpdate(DocumentEvent e) { int index = searchResultModel.indexOf(editDataPanel.getData()); if (index >= 0) { searchResultModel.set(index, editDataPanel.getData()); } } }); searchField.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showTextPopup(e); } else { // searchField.selectAll(); } } @Override public void mouseReleased(MouseEvent e) { showTextPopup(e); } }); // searchField.addFocusListener(new FocusListener() { // @Override // public void focusLost(FocusEvent e) { // System.out.println("MainPanel.MainPanel().new FocusListener() {...}.focusLost()"); // } // // @Override // public void focusGained(FocusEvent e) { // System.out.println("MainPanel.MainPanel().new FocusListener() {...}.focusGained()"); // //searchField.selectAll(); // } // }); }
From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { popMenu.show(e.getComponent(), e.getX(), e.getY()); } }
From source file:Main.java
public static MouseEvent convertMouseEvent(Component source, MouseEvent sourceEvent, Component destination) { Point p = SwingUtilities.convertPoint(source, new Point(sourceEvent.getX(), sourceEvent.getY()), destination);// w w w. j a v a 2s . co m Component newSource; if (destination != null) newSource = destination; else newSource = source; MouseEvent newEvent; if (sourceEvent instanceof MouseWheelEvent) { MouseWheelEvent sourceWheelEvent = (MouseWheelEvent) sourceEvent; newEvent = new MouseWheelEvent(newSource, sourceWheelEvent.getID(), sourceWheelEvent.getWhen(), sourceEvent.getModifiers() | sourceEvent.getModifiersEx(), p.x, p.y, sourceWheelEvent.getClickCount(), sourceWheelEvent.isPopupTrigger(), sourceWheelEvent.getScrollType(), sourceWheelEvent.getScrollAmount(), sourceWheelEvent.getWheelRotation()); } else if (sourceEvent instanceof MenuDragMouseEvent) { MenuDragMouseEvent sourceMenuDragEvent = (MenuDragMouseEvent) sourceEvent; newEvent = new MenuDragMouseEvent(newSource, sourceMenuDragEvent.getID(), sourceMenuDragEvent.getWhen(), sourceEvent.getModifiers() | sourceEvent.getModifiersEx(), p.x, p.y, sourceMenuDragEvent.getClickCount(), sourceMenuDragEvent.isPopupTrigger(), sourceMenuDragEvent.getPath(), sourceMenuDragEvent.getMenuSelectionManager()); } else { newEvent = new MouseEvent(newSource, sourceEvent.getID(), sourceEvent.getWhen(), sourceEvent.getModifiers() | sourceEvent.getModifiersEx(), p.x, p.y, sourceEvent.getClickCount(), sourceEvent.isPopupTrigger(), sourceEvent.getButton()); } return newEvent; }
From source file:de.tntinteractive.portalsammler.gui.DocumentTable.java
public DocumentTable(final Gui gui, final SecureStore store) { this.gui = gui; this.store = store; this.table = new JTable(); this.table.setRowSelectionAllowed(true); this.refreshContents(); this.table.addMouseListener(new MouseAdapter() { @Override/* w w w. j ava 2 s .c om*/ public void mousePressed(final MouseEvent me) { final int r = DocumentTable.this.table.rowAtPoint(me.getPoint()); if (!DocumentTable.this.table.getSelectionModel().isSelectedIndex(r)) { if (r >= 0 && r < DocumentTable.this.table.getRowCount()) { DocumentTable.this.table.setRowSelectionInterval(r, r); } else { DocumentTable.this.table.clearSelection(); } } if (me.isPopupTrigger()) { DocumentTable.this.showPopup(me); } else if (me.getClickCount() == 2) { DocumentTable.this.openSelectedRows(); } } @Override public void mouseReleased(final MouseEvent me) { if (me.isPopupTrigger()) { DocumentTable.this.showPopup(me); } } }); this.table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); this.table.getColumnModel().getColumn(0).setPreferredWidth(120); this.table.getColumnModel().getColumn(1).setPreferredWidth(80); this.table.getColumnModel().getColumn(2).setPreferredWidth(100); this.table.getColumnModel().getColumn(3).setPreferredWidth(500); }
From source file:org.fhaes.jsea.JSEAFrame.java
/** * Show popup menu/* w w w. j a v a2 s . c o m*/ * * @param component * @param popup */ private static void addPopup(Component component, final JPopupMenu popup) { component.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e); } } private void showMenu(MouseEvent e) { popup.show(e.getComponent(), e.getX(), e.getY()); } }); }
From source file:org.zaproxy.zap.extension.multiFuzz.impl.http.HttpFuzzResultDialog.java
@Override public JXTreeTable getTable() { if (table == null) { if (model == null) { model = new HttpFuzzTableModel(); }/*from www . j a va 2s.c o m*/ table = new JXTreeTable(model); table.setDoubleBuffered(true); table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION); table.setName("HttpFuzzResultTable"); table.setFont(new java.awt.Font("Default", java.awt.Font.PLAIN, 12)); table.setDefaultRenderer(Pair.class, new IconTableCellRenderer()); int[] widths = { 10, 25, 550, 30, 85, 55, 40, 70 }; for (int i = 0, count = widths.length; i < count; i++) { TableColumn column = table.getColumnModel().getColumn(i); column.setPreferredWidth(widths[i]); } table.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mousePressed(java.awt.event.MouseEvent e) { showPopupMenuIfTriggered(e); } @Override public void mouseReleased(java.awt.event.MouseEvent e) { showPopupMenuIfTriggered(e); } private void showPopupMenuIfTriggered(java.awt.event.MouseEvent e) { if (e.isPopupTrigger()) { if (e.isPopupTrigger()) { // Select list item on right click JTable table = (JTable) e.getSource(); int row = table.rowAtPoint(e.getPoint()); if (!table.isRowSelected(row)) { table.changeSelection(row, 0, false, false); } View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY()); } } } }); table.getSelectionModel().addListSelectionListener(new javax.swing.event.ListSelectionListener() { @Override public void valueChanged(javax.swing.event.ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (table.getSelectedRowCount() == 0) { return; } final int row = table.getSelectedRow(); if (getEntry(row) instanceof HttpFuzzRequestRecord) { final HistoryReference historyReference = ((HttpFuzzRequestRecord) getEntry(row)) .getHistory(); try { getMessageInspection().setMessage(historyReference.getHttpMessage()); } catch (HttpMalformedHeaderException | SQLException ex) { logger.error(ex.getMessage(), ex); } } updateValues(); redrawDiagrams(); } } }); } table.getTableHeader().addMouseListener(new MouseListener() { int sortedOn = -1; @Override public void mouseReleased(MouseEvent arg0) { } @Override public void mousePressed(MouseEvent arg0) { } @Override public void mouseExited(MouseEvent arg0) { } @Override public void mouseEntered(MouseEvent arg0) { } @Override public void mouseClicked(MouseEvent e) { int index = table.columnAtPoint(e.getPoint()); List<HttpFuzzRecord> list = model.getEntries(); if (list.size() == 0) { return; } HttpFuzzRecordComparator comp = new HttpFuzzRecordComparator(); comp.setFeature(index); if (index == sortedOn) { Collections.sort(list, comp); Collections.reverse(list); sortedOn = -1; } else { Collections.sort(list, comp); sortedOn = index; } table.updateUI(); } }); table.setRootVisible(false); table.setVisible(true); return table; }