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());
}
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());
}
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");
}
}
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.");
}
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;
}
}
Aggregations