Search in sources :

Example 16 with JPopupMenu

use of javax.swing.JPopupMenu in project binnavi by google.

the class CCodeBookmarkTable method showPopup.

/**
   * Shows a context menu.
   *
   * @param event Mouse-event that triggered the context menu.
   */
private void showPopup(final MouseEvent event) {
    int[] rows = getSelectedRows();
    // where the click happened.
    if ((rows.length == 0) || (rows.length == 1)) {
        final int row = rowAtPoint(event.getPoint());
        final int column = columnAtPoint(event.getPoint());
        // Apparently no row was properly hit
        if ((row == -1) || (column == -1)) {
            return;
        }
        changeSelection(row, column, false, false);
        rows = getSelectedRows();
    }
    final JPopupMenu menu = new JPopupMenu();
    menu.add(new JMenuItem(CActionProxy.proxy(new CDeleteBookmarkAction(m_bookmarkManager, rows))));
    menu.show(event.getComponent(), event.getX(), event.getY());
}
Also used : CDeleteBookmarkAction(com.google.security.zynamics.binnavi.Gui.CodeBookmarks.Actions.CDeleteBookmarkAction) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu)

Example 17 with JPopupMenu

use of javax.swing.JPopupMenu in project binnavi by google.

the class CStackView method showPopupMenu.

/**
   * Shows the stack window context menu.
   *
   * @param event Mouse event that describes the click on the stack window.
   */
private void showPopupMenu(final MouseEvent event) {
    final JPopupMenu menu = new CStackViewMenu(m_stackView, m_model, event.getPoint());
    menu.show(this, event.getX(), event.getY());
}
Also used : JPopupMenu(javax.swing.JPopupMenu)

Example 18 with JPopupMenu

use of javax.swing.JPopupMenu in project jdk8u_jdk by JetBrains.

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    //runTest(new JScrollBar()); --> don't test defines max and min in
    // terms of preferred
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 19 with JPopupMenu

use of javax.swing.JPopupMenu in project jdk8u_jdk by JetBrains.

the class GrabOnUnfocusableToplevel method main.

public static void main(String[] args) {
    Robot r = Util.createRobot();
    JWindow w = new JWindow();
    w.setSize(100, 100);
    w.setVisible(true);
    Util.waitForIdle(r);
    final JPopupMenu menu = new JPopupMenu();
    JButton item = new JButton("A button in popup");
    menu.add(item);
    w.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent me) {
            menu.show(me.getComponent(), me.getX(), me.getY());
            System.out.println("Showing menu at " + menu.getLocationOnScreen() + " isVisible: " + menu.isVisible() + " isValid: " + menu.isValid());
        }
    });
    Util.clickOnComp(w, r);
    Util.waitForIdle(r);
    if (!menu.isVisible()) {
        throw new RuntimeException("menu was not shown");
    }
    menu.hide();
    System.out.println("Test passed.");
}
Also used : MouseEvent(java.awt.event.MouseEvent) JWindow(javax.swing.JWindow) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) Robot(java.awt.Robot) JPopupMenu(javax.swing.JPopupMenu)

Example 20 with JPopupMenu

use of javax.swing.JPopupMenu in project jdk8u_jdk by JetBrains.

the class bug8071705 method runActualTest.

private static void runActualTest(GraphicsDevice device, CountDownLatch latch, JFrame frame, boolean[] result) {
    Rectangle screenBounds = setLocation(frame, device);
    JMenu menu = frame.getJMenuBar().getMenu(0);
    menu.doClick();
    Point location = menu.getLocationOnScreen();
    JPopupMenu pm = menu.getPopupMenu();
    Dimension pmSize = pm.getSize();
    int yOffset = UIManager.getInt("Menu.submenuPopupOffsetY");
    int height = location.y + yOffset + pmSize.height + menu.getHeight();
    int available = screenBounds.y + screenBounds.height - height;
    if (available > 0) {
        Point origin = pm.getLocationOnScreen();
        if (origin.y < location.y) {
            // growing upward, wrong!
            result[0] = false;
        } else {
            // growing downward, ok!
            result[0] = true;
        }
    } else {
        // there is no space, growing upward would be ok, so we pass
        result[0] = true;
    }
}
Also used : Rectangle(java.awt.Rectangle) Point(java.awt.Point) Dimension(java.awt.Dimension) JMenu(javax.swing.JMenu) JPopupMenu(javax.swing.JPopupMenu) Point(java.awt.Point)

Aggregations

JPopupMenu (javax.swing.JPopupMenu)128 JMenuItem (javax.swing.JMenuItem)56 ActionEvent (java.awt.event.ActionEvent)34 ActionListener (java.awt.event.ActionListener)20 JMenu (javax.swing.JMenu)19 Component (java.awt.Component)17 JButton (javax.swing.JButton)16 JScrollPane (javax.swing.JScrollPane)15 AbstractAction (javax.swing.AbstractAction)14 JLabel (javax.swing.JLabel)14 MouseEvent (java.awt.event.MouseEvent)13 Point (java.awt.Point)11 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)11 JSeparator (javax.swing.JSeparator)11 JPanel (javax.swing.JPanel)10 JTable (javax.swing.JTable)10 Dimension (java.awt.Dimension)7 ArrayList (java.util.ArrayList)7 JTextArea (javax.swing.JTextArea)7 JCheckBox (javax.swing.JCheckBox)6