javax.swing.JPopupMenu#getInvoker ( )源码实例Demo

下面列出了javax.swing.JPopupMenu#getInvoker ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: aurous-app   文件: TabelPanel.java
@Override
public void actionPerformed(final ActionEvent e) {
	final Component c = (Component) e.getSource();
	final JPopupMenu popup = (JPopupMenu) c.getParent();
	final JTable table = (JTable) popup.getInvoker();

	switch (e.getActionCommand()) {
	case "Delete":
		Playlist.getPlaylist().removeSelectedRows(table);
		break;
	case "Play":
		MediaUtils.switchMedia(table);
		break;
	case "Share":
		// System.out.println("Sharing");
		break;
	case "Copy URL":
		MediaUtils.copyMediaURL(table);
		break;
	}
	// System.out.println(table.getSelectedRow() + " : " +
	// table.getSelectedColumn());
}
 
源代码2 项目: aurous-app   文件: PlayListPanel.java
@Override
public void actionPerformed(final ActionEvent e) {
	final Component c = (Component) e.getSource();
	final JPopupMenu popup = (JPopupMenu) c.getParent();
	final JList<?> list = (JList<?>) popup.getInvoker();
	final Object o = list.getSelectedValue();
	final String playlist = o.toString();
	switch (e.getActionCommand()) {
	case "Delete":
		Playlist.getPlaylist().deletePlayList(list);
		break;
	case "Play":
		ModelUtils.loadPlayList(playlist);
		PlayerFunctions.seekNext();
		break;
	case "Load":
		ModelUtils.loadPlayList(playlist);

		break;
	case "Share":
		// System.out.println("Sharing");
		break;
	}
	// System.out.println(table.getSelectedRow() + " : " +
	// table.getSelectedColumn());
}
 
源代码3 项目: marathonv5   文件: RMenuItem.java
private String buildMenuElementArray(JMenuItem leaf) {
    Vector<JMenuItem> elements = new Vector<JMenuItem>();

    elements.insertElementAt(leaf, 0);
    Component current = leaf.getParent();

    while (current != null) {
        if (current instanceof JPopupMenu) {
            JPopupMenu pop = (JPopupMenu) current;
            current = pop.getInvoker();
        } else if (current instanceof JMenu) {
            JMenu menu = (JMenu) current;
            elements.insertElementAt(menu, 0);
            current = menu.getParent();
        } else if (current instanceof JMenuBar) {
            break;
        } else {
            current = current.getParent();
        }
    }
    mainMenu = elements.get(0);
    JMenuItem parent = null;
    StringBuilder sb = new StringBuilder();
    RComponentFactory finder = new RComponentFactory(omapConfig);
    for (JMenuItem jMenuItem : elements) {
        RComponent rComponent = finder.findRComponent(jMenuItem, null, recorder);
        recorder.recordMenuItem(rComponent);
        String text = JMenuItemJavaElement.getText(JMenuItemJavaElement.getItemText(jMenuItem), jMenuItem,
                parent == null ? new Component[0] : ((JMenu) parent).getMenuComponents());
        parent = jMenuItem;
        sb.append(text).append(">>");
    }
    sb.setLength(sb.length() - 2);
    return sb.toString();
}
 
源代码4 项目: IrScrutinizer   文件: CopyPastePopupMenu.java
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
    JMenuItem jmi = (JMenuItem) evt.getSource();
    Container container = jmi.getParent();
    assert(container instanceof JPopupMenu);
    JPopupMenu jpm = (JPopupMenu) container;
    JTextComponent jtf = (JTextComponent) jpm.getInvoker();
    (new CopyClipboardText(null)).toClipboard(jtf.getText());
}
 
源代码5 项目: IrScrutinizer   文件: CopyPastePopupMenu.java
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
    JMenuItem jmi = (JMenuItem) evt.getSource();
    Container container = jmi.getParent();
    assert(container instanceof JPopupMenu);
    JPopupMenu jpm = (JPopupMenu) container;
    JTextComponent jtf = (JTextComponent) jpm.getInvoker();
    jtf.setText((new CopyClipboardText(null)).fromClipboard());
}
 
源代码6 项目: netbeans   文件: JPopupMenuUtils.java
public static void dynamicChangeToSubmenu(JPopupMenu popup, boolean usedToBeContained) {
    Object invoker = popup.getInvoker();

    if (!(invoker instanceof JMenu)) {
        return;
    }

    JMenu menu = (JMenu) invoker;

    if (!popup.isShowing()) {
        return;
    }

    if (isProblemConfig()) {
        callRefreshLater2(popup, menu);

        return;
    }

    refreshPopup(popup);

    Point p = popup.getLocationOnScreen();
    Dimension popupSize = popup.getPreferredSize();
    Rectangle popupRect = new Rectangle(p, popupSize);
    Rectangle screenRect = getScreenRect();
    boolean willBeContained = isPopupContained(popup);

    if (!screenRect.contains(popupRect)) {
        /*
         * The menu grew off the edge of the screen.
         */
        menu.setPopupMenuVisible(false);
        menu.setPopupMenuVisible(true);
    } else if (usedToBeContained != willBeContained) {
        /*
         * The menu grew off the edge of the containing window.
         * Use the setVisible() hack to change the menu from
         * lightweight to heavyweight.
         */
        popup.setVisible(false);
        popup.setVisible(true);
    }
}
 
源代码7 项目: seaglass   文件: PopupMenuPainter.java
/**
 * @param c
 * @return
 */
private Component getInvoker(JComponent c) {
    JPopupMenu popup = (JPopupMenu) c;
    return popup.getInvoker();
}