List of usage examples for java.awt.event MouseEvent isPopupTrigger
public boolean isPopupTrigger()
From source file:nl.detoren.ijsco.ui.Mainscreen.java
public JPanel createDeelnemersPanel() { JPanel panel = new JPanel(false); panel.setBackground(Color.BLACK); //panel.setLayout(new GridLayout(1, 0)); panel.setLayout(new BorderLayout()); JPanel innerPanel = new JPanel(); JLabel lbAanwezig = new JLabel("Deelnemers: "); innerPanel.add(lbAanwezig, BorderLayout.NORTH); tfAanwezig = new JLabel(Integer.toString(status.deelnemers.aantalAanwezig()), 10); innerPanel.add(tfAanwezig, BorderLayout.NORTH); //innerPanel.setLayout(new GridLayout(1, 0)); innerPanel.add(new JLabel("Naam:"), BorderLayout.NORTH); JTextField deelnemer = new JTextField(15); ArrayList<String> words = new ArrayList<>(); if (status.OSBOSpelers != null) { for (Speler s : status.OSBOSpelers.values()) { words.add(s.getNaam().trim()); words.add(Integer.toString(s.getKnsbnummer())); }/*from w w w . ja v a 2s . c om*/ } @SuppressWarnings("unused") Suggesties suggesties = new Suggesties(deelnemer, this, words, 2); innerPanel.add(deelnemer, BorderLayout.NORTH); deelnemer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { actieVoegSpelerToe(deelnemer.getText().trim()); deelnemer.setText(""); } }); JButton btVoegToe = new JButton("Voeg toe"); btVoegToe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { actieVoegSpelerToe(deelnemer.getText().trim()); deelnemer.setText(""); } }); innerPanel.add(btVoegToe); panel.add(innerPanel); // panel_deelnemers.add(new JLabel("Deelnemers IJSCO toernooi")); deelnemersModel = new DeelnemersModel(panel, status.deelnemers); JTable deelnemersTabel = new JTable(deelnemersModel) { private static final long serialVersionUID = -8293073016982337108L; @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); DeelnemersModel model = (DeelnemersModel) getModel(); // Tooltip if (c instanceof JComponent) { ((JComponent) c) .setToolTipText(model.getToolTip(convertRowIndexToModel(row), column).toString()); } // Alternate row color if (!isRowSelected(row)) { c.setBackground(row % 2 == 0 ? Color.WHITE : Color.LIGHT_GRAY); } // Highlight overruled entries if (status.deelnemers.get(convertRowIndexToModel(row)).isOverruleNaam() || status.deelnemers.get(convertRowIndexToModel(row)).isOverruleNaam()) { c.setForeground(Color.BLUE); } else { c.setForeground(Color.BLACK); } return c; } }; deelnemersTabel.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { status.groepen = null; status.schemas = null; status.schema = null; groepenText.setText(""); schemaModel.setSchemas(null); schemaModel.fireTableDataChanged(); if (status.deelnemers != null && tfAanwezig != null) { tfAanwezig.setText(Integer.toString(status.deelnemers.aantalAanwezig())); } panel.repaint(); } }); deelnemersTabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { logger.log(Level.INFO, "MouseEvent on table fired, type : " + e.toString()); logger.log(Level.INFO, "Popup trigger? : " + e.isPopupTrigger()); if (e.isPopupTrigger()) { int row = deelnemersTabel.rowAtPoint(e.getPoint()); JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Bewerk speler"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logger.log(Level.INFO, "Bewerk Speler : " + deelnemersTabel.convertRowIndexToModel(row)); Speler s = status.deelnemers.get(deelnemersTabel.convertRowIndexToModel(row)); BewerkSpelerDialoog rd = new BewerkSpelerDialoog(new JFrame(), "Bewerk Speler", s, deelnemersModel); rd.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { System.out.println("closing..."); } }); rd.setVisible(true); } }); popup.add(menuItem); menuItem = new JMenuItem("Verwijder Speler"); popup.add(menuItem); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logger.log(Level.INFO, "Verwijder Speler : " + deelnemersTabel.convertRowIndexToModel(row)); Speler s = status.deelnemers.get(deelnemersTabel.convertRowIndexToModel(row)); status.deelnemers.remove(s); deelnemersModel.fireTableDataChanged(); } }); popup.show(e.getComponent(), e.getX(), e.getY()); } } }); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(deelnemersTabel); innerPanel.add(scrollPane, BorderLayout.CENTER); TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(deelnemersModel); deelnemersTabel.setRowSorter(sorter); innerPanel.add(new JLabel("Filter op : ")); JTextField tfFilter = new JTextField(10); tfFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String text = tfFilter.getText(); logger.log(Level.INFO, "Filter tabel op : " + text); if (text.length() == 0) { sorter.setRowFilter(null); } else { sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text)); } } }); innerPanel.add(tfFilter); JButton btPasToe = new JButton("Apply"); btPasToe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String text = tfFilter.getText(); logger.log(Level.INFO, "Filter tabel op : " + text); if (text.length() == 0) { sorter.setRowFilter(null); } else { sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text)); } } }); innerPanel.add(btPasToe); JButton btWis = new JButton("Wis"); btWis.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { tfFilter.setText(""); logger.log(Level.INFO, "Wis filter"); sorter.setRowFilter(null); } }); innerPanel.add(btWis); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(0), 30); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(1), 55); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(2), 170); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(3), 40); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(4), 40); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(5), 30); Utils.fixedComponentSize(scrollPane, 400, 580); return panel; }
From source file:nz.ac.massey.cs.gql4jung.browser.ResultBrowser.java
private void initPopupMenu() { popup = new JPopupMenu(); popup.add(this.actRunQuery); popup.add(this.actCancelQuery); popup.addSeparator();/*www. j a va 2s . com*/ popup.add(this.actLoadData); popup.add(this.actLoadQuery); popup.addSeparator(); popup.add(this.actNextMajorInstance); popup.add(this.actPreviousMajorInstance); popup.addSeparator(); popup.add(this.actNextMinorInstance); popup.add(this.actPreviousMinorInstance); popupListener = new MouseAdapter() { public void mousePressed(MouseEvent e) { showPopup(e); } public void mouseReleased(MouseEvent e) { showPopup(e); } private void showPopup(MouseEvent e) { if (e.isPopupTrigger()) { popup.show(e.getComponent(), e.getX(), e.getY()); } } }; this.mainPanel.addMouseListener(popupListener); }
From source file:nz.govt.natlib.ndha.manualdeposit.bulkupload.BulkUploadPresenter.java
private void tblJobListMouseReleased(final java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { if (theJobListTable.getSelectedRowCount() == 0) { final int row = theJobListTable.rowAtPoint(evt.getPoint()); if (row > -1) { theJobListTable.setRowSelectionInterval(row, row); }/*from w w w . j av a 2s . c om*/ } final JPopupMenu menu = bulkUploadManager.getBulkUploadMenu(); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); } } }
From source file:nz.govt.natlib.ndha.manualdeposit.bulkupload.BulkUploadPresenter.java
private void tableMouseClicked(final java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { if (theJobListTable.getSelectedRowCount() == 0) { final int row = theJobListTable.rowAtPoint(evt.getPoint()); if (row > -1) { theJobListTable.setRowSelectionInterval(row, row); }//w w w . jav a 2s. c o m } final JPopupMenu menu = bulkUploadManager.getBulkUploadMenu(); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); } } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void jobQueueMousePressedCommon(java.awt.event.MouseEvent evt, JTable table) { if (evt.isPopupTrigger()) { if (table.getSelectedRowCount() == 0) { int row = table.rowAtPoint(evt.getPoint()); if (row > -1) { table.setRowSelectionInterval(row, row); }//from www . j a v a 2 s. c o m } JPopupMenu menu = depositPresenter.getJobQueueMenu((JTable) evt.getSource()); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); } } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void jobQueueMouseReleaseCommon(java.awt.event.MouseEvent evt, JTable table) { if (evt.isPopupTrigger()) { if (table.getSelectedRowCount() == 0) { int row = table.rowAtPoint(evt.getPoint()); if (row > -1) { table.setRowSelectionInterval(row, row); }/*from w w w .j a v a 2s . c om*/ } JPopupMenu menu = depositPresenter.getJobQueueMenu((JTable) evt.getSource()); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); } } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void lstProducersMousePressed(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { JPopupMenu menu = depositPresenter.getProducerMenu(); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); }/*from ww w . jav a 2 s.com*/ } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void lstProducersMouseReleased(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { JPopupMenu menu = depositPresenter.getProducerMenu(); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); }/*w ww . j a v a2 s.c om*/ } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void treeStructMapMousePressed(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { TreePath path = treeStructMap.getClosestPathForLocation(evt.getX(), evt.getY()); if (path != null) { treeStructMap.setSelectionPath(path); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); JPopupMenu menu = depositPresenter.getStructMapMenu(node); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); }/* w w w .j a v a 2s. c o m*/ } } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void treeEntitiesMousePressed(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { TreePath path = treeEntities.getClosestPathForLocation(evt.getX(), evt.getY()); if (path != null) { treeEntities.setSelectionPath(path); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); JPopupMenu menu = depositPresenter.getEntityMenu(node); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); }//from www. ja va2 s .co m } } else { setDragSourceEntity(); } }