Java Code Examples for javax.swing.JPopupMenu#setInvoker()
The following examples show how to use
javax.swing.JPopupMenu#setInvoker() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingsPage.java From xdm with GNU General Public License v2.0 | 6 votes |
private void showMoveQPopup(JButton btn) { int index = qList.getSelectedIndex(); if (index < 0) { return; } DownloadQueue q = queueModel.get(index); String qid = q.getQueueId(); if (qid == null) return; JPopupMenu popupMenu = new JPopupMenu(); for (int i = 0; i < QueueManager.getInstance().getQueueList().size(); i++) { DownloadQueue tq = QueueManager.getInstance().getQueueList().get(i); if (qid.equals(tq.getQueueId())) { continue; } JMenuItem item = new JMenuItem(tq.getName()); item.setName("Q_MOVE_TO:" + tq.getQueueId()); item.addActionListener(this); item.setForeground(Color.WHITE); item.setFont(FontResource.getNormalFont()); popupMenu.add(item); } popupMenu.setInvoker(btn); popupMenu.show(btn, 0, btn.getHeight()); }
Example 2
Source File: VideoDownloadWindow.java From xdm with GNU General Public License v2.0 | 6 votes |
private void createPopup() { pop = new JPopupMenu(); pop.setBackground(ColorResource.getDarkerBgColor()); JMenu dl = new JMenu(StringResource.get("ND_DOWNLOAD_LATER")); dl.setForeground(Color.WHITE); dl.setBorder(new EmptyBorder(getScaledInt(5), getScaledInt(5), getScaledInt(5), getScaledInt(5))); dl.addActionListener(this); dl.setBackground(ColorResource.getDarkerBgColor()); dl.setBorderPainted(false); // dl.setBackground(C); pop.add(dl); createQueueItems(dl); JMenuItem ig = new JMenuItem(StringResource.get("ND_IGNORE_URL")); ig.setName("IGNORE_URL"); ig.setForeground(Color.WHITE); ig.addActionListener(this); pop.add(ig); pop.setInvoker(btnMore); }
Example 3
Source File: NewDownloadWindow.java From xdm with GNU General Public License v2.0 | 6 votes |
private void createPopup() { pop = new JPopupMenu(); pop.setBackground(ColorResource.getDarkerBgColor()); JMenu dl = new JMenu(StringResource.get("ND_DOWNLOAD_LATER")); dl.setForeground(Color.WHITE); dl.setBorder(new EmptyBorder(getScaledInt(5), getScaledInt(5), getScaledInt(5), getScaledInt(5))); dl.addActionListener(this); dl.setBackground(ColorResource.getDarkerBgColor()); dl.setBorderPainted(false); // dl.setBackground(C); pop.add(dl); createQueueItems(dl); JMenuItem ig = new JMenuItem(StringResource.get("ND_IGNORE_URL")); ig.setName("IGNORE_URL"); ig.setForeground(Color.WHITE); ig.addActionListener(this); pop.add(ig); pop.setInvoker(btnMore); }
Example 4
Source File: ButtonPopupSwitcher.java From netbeans with Apache License 2.0 | 6 votes |
private void doSelect(JComponent owner) { invokingComponent = owner; invokingComponent.addMouseListener(this); invokingComponent.addMouseMotionListener(this); pTable.addMouseListener(this); pTable.addMouseMotionListener(this); pTable.getSelectionModel().addListSelectionListener( this ); displayer.getModel().addComplexListDataListener( this ); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); popup = new JPopupMenu(); popup.setBorderPainted( false ); popup.setBorder( BorderFactory.createEmptyBorder() ); popup.add( pTable ); popup.pack(); int locationX = x - (int) pTable.getPreferredSize().getWidth(); int locationY = y + 1; popup.setLocation( locationX, locationY ); popup.setInvoker( invokingComponent ); popup.addPopupMenuListener( this ); popup.setVisible( true ); shown = true; invocationTime = System.currentTimeMillis(); }
Example 5
Source File: ButtonPopupSwitcher.java From netbeans with Apache License 2.0 | 6 votes |
private void doSelect(JComponent owner) { invokingComponent = owner; invokingComponent.addMouseListener(this); invokingComponent.addMouseMotionListener(this); pTable.addMouseListener(this); pTable.addMouseMotionListener(this); pTable.getSelectionModel().addListSelectionListener( this ); controller.getTabModel().addComplexListDataListener( this ); Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); popup = new JPopupMenu(); popup.setBorderPainted( false ); popup.setBorder( BorderFactory.createEmptyBorder() ); popup.add( pTable ); popup.pack(); int locationX = x - (int) pTable.getPreferredSize().getWidth(); int locationY = y + 1; popup.setLocation( locationX, locationY ); popup.setInvoker( invokingComponent ); popup.addPopupMenuListener( this ); popup.setVisible( true ); shown = true; invocationTime = System.currentTimeMillis(); }
Example 6
Source File: OutputTab.java From netbeans with Apache License 2.0 | 6 votes |
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { JPopupMenu popup = (JPopupMenu) e.getSource(); popup.removeAll(); popup.setInvoker(null); // hack KeyStroke esc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); JComponent c = getOutputPane().getTextView(); c.getInputMap().put(esc, handle); getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(esc, handle); //hack end popup.removePopupMenuListener(this); for (TabAction action : popupItems) { action.clearListeners(); } }
Example 7
Source File: MainWindow.java From xdm with GNU General Public License v2.0 | 5 votes |
private void prepeareQueuePopupButton() { final JPopupMenu popQ = new JPopupMenu(); ArrayList<DownloadQueue> qlist = QueueManager.getInstance().getQueueList(); JMenuItem[] qItems = new JMenuItem[qlist.size() + 1]; qItems[0] = new JMenuItem(StringResource.get("LBL_ALL_QUEUE")); qItems[0].setName("Q_VIEW:ALL"); popQ.add(qItems[0]); qItems[0].addActionListener(this); int index = -1; for (int i = 0; i < qlist.size(); i++) { String qId = qlist.get(i).getQueueId(); DownloadQueue q = qlist.get(i); qItems[i + 1] = new JMenuItem(q.getName() + (q.isRunning() ? "*" : "")); qItems[i + 1].setName("Q_VIEW:" + qId); qItems[i + 1].addActionListener(this); popQ.add(qItems[i + 1]); String selectedQ = Config.getInstance().getQueueIdFilter(); if (index == -1) { if (selectedQ != null && selectedQ.equals(qId)) { index = i + 1; } } } if (index == -1) { index = 0; } qItems[index].setFont(FontResource.getBoldFont()); qItems[index].setForeground(ColorResource.getLightFontColor()); popQ.setInvoker(btnQueue); popQ.show(btnQueue, 0, btnQueue.getHeight()); }
Example 8
Source File: CommitMessageMouseAdapter.java From netbeans with Apache License 2.0 | 5 votes |
/** * Shows the popup popupMenu if the invoker is a instance of JTextComponent. */ private void show(Component invoker, int x, int y) { //to avoid class cast exception in action listener if (invoker instanceof JTextComponent) { JTextComponent textComponent = (JTextComponent)invoker; JPopupMenu popupMenu = popupBuilder.getPopup(textComponent); popupMenu.setInvoker(invoker); popupMenu.show(invoker, x, y); } }
Example 9
Source File: ObjectTree.java From bigtable-sql with Apache License 2.0 | 5 votes |
public void dispose() { // Menues that are also shown in the main window Session menu might // be in this popup. If we don't remove them, the Session won't be Garbage Collected. _globalPopup.removeAll(); _globalPopup.setInvoker(null); _globalActions.clear(); for(Iterator<JPopupMenu> i=_popups.values().iterator(); i.hasNext();) { JPopupMenu popup = i.next(); popup.removeAll(); popup.setInvoker(null); } _popups.clear(); }
Example 10
Source File: XDMFileSelectionPanel.java From xdm with GNU General Public License v2.0 | 4 votes |
private void initUI() { setBackground(ColorResource.getDarkestBgColor()); txtFile = new JTextField(); setBorder(new LineBorder(ColorResource.getSelectionColor(), 1)); txtFile.setBackground(ColorResource.getDarkestBgColor()); txtFile.setBorder(null); txtFile.setForeground(Color.WHITE); txtFile.setBounds(getScaledInt(77), getScaledInt(111), getScaledInt(241), getScaledInt(20)); txtFile.setCaretColor(ColorResource.getSelectionColor()); add(txtFile); Box hbox = Box.createHorizontalBox(); btnBrowse = new CustomButton(); btnBrowse.setBackground(ColorResource.getDarkestBgColor()); btnBrowse.setIcon(ImageResource.getIcon("folder.png", 16, 16)); btnBrowse.setMargin(new Insets(0, 0, 0, 0)); btnBrowse.setContentAreaFilled(false); btnBrowse.setBorderPainted(false); btnBrowse.setFocusPainted(false); btnBrowse.setOpaque(false); btnBrowse.addActionListener(this); btnDropdown = new CustomButton(); btnDropdown.setBackground(ColorResource.getDarkestBgColor()); btnDropdown.setIcon(ImageResource.getIcon("down_white.png",16,16)); btnDropdown.setMargin(new Insets(0, 0, 0, 0)); btnDropdown.setContentAreaFilled(false); btnDropdown.setBorderPainted(false); btnDropdown.setFocusPainted(false); btnDropdown.addActionListener(this); hbox.add(btnBrowse); hbox.add(btnDropdown); add(hbox, BorderLayout.EAST); pop = new JPopupMenu(); if (!StringUtils.isNullOrEmptyOrBlank(Config.getInstance().getLastFolder())) { pop.add(createMenuItem(Config.getInstance().getLastFolder())); } pop.add(createMenuItem(Config.getInstance().getDownloadFolder())); if (!Config.getInstance().isForceSingleFolder()) { pop.add(createMenuItem(Config.getInstance().getCategoryDocuments())); pop.add(createMenuItem(Config.getInstance().getCategoryMusic())); pop.add(createMenuItem(Config.getInstance().getCategoryPrograms())); pop.add(createMenuItem(Config.getInstance().getCategoryCompressed())); pop.add(createMenuItem(Config.getInstance().getCategoryVideos())); } pop.setInvoker(btnDropdown); }
Example 11
Source File: MainWindow.java From xdm with GNU General Public License v2.0 | 4 votes |
private void createPopupMenu() { popupCtx = new JPopupMenu(); addMenuItem("CTX_OPEN_FILE", popupCtx); addMenuItem("CTX_OPEN_FOLDER", popupCtx); addMenuItem("CTX_SAVE_AS", popupCtx); addMenuItem("MENU_PAUSE", popupCtx); addMenuItem("MENU_RESUME", popupCtx); addMenuItem("MENU_DELETE_DWN", popupCtx); addMenuItem("MENU_REFRESH_LINK", popupCtx); addMenuItem("DWN_PREVIEW", popupCtx); addMenuItem("LBL_SHOW_PROGRESS", popupCtx); addMenuItem("CTX_COPY_URL", popupCtx); addMenuItem("CTX_COPY_FILE", popupCtx); addMenuItem("OPT_CONVERT", popupCtx); // convertMenu = createMenu(StringResource.get("OPT_CONVERT")); // convertMenu.setBorder(new EmptyBorder(5, 10, 5, 5)); // convertMenu.setFont(FontResource.getNormalFont()); // // MediaFormat[] fmts = MediaFormats.getSupportedFormats(); // for (int i = 1; i < fmts.length; i++) { // MediaFormat fmt = fmts[i]; // JMenuItem mitem = new JMenuItem(fmt.toString()); // mitem.setName("FORMAT=" + i); // mitem.addActionListener(this); // convertMenu.add(mitem); // } // // popupCtx.add(convertMenu); addMenuItem("MENU_PROPERTIES", popupCtx); popupCtx.setInvoker(lv.getTable()); lv.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { System.out.println("Opening file"); openFile(); } } @Override public void mouseReleased(MouseEvent me) { // JOptionPane.showMessageDialog(null,"Mouse clicked: // "+me.getButton()+" "+MouseEvent.BUTTON3); if (me.getButton() == MouseEvent.BUTTON3 || SwingUtilities.isRightMouseButton(me) || me.isPopupTrigger() || XDMUtils.isMacPopupTrigger(me)) { Point p = me.getPoint(); JTable tbl = lv.getTable(); if (tbl.getRowCount() < 1) return; if (tbl.getSelectedRow() < 0) { int row = tbl.rowAtPoint(p); if (row >= 0) { tbl.setRowSelectionInterval(row, row); } } if (tbl.getSelectedRows().length > 0) { popupCtx.show(lv.getTable(), me.getX(), me.getY()); } // int row = tbl.rowAtPoint(p); // if (row < 0) { // tbl.setRowSelectionInterval(row, row); // } } } }); }