posted 21 years ago
Hi Pascal,
I don't understand your second question.
For the first question, try this
(1) Calculete your Jpopupmenu size
JPopupMenu popup = new JPopupMenu();
Dimension popupSize = popup.getPreferredSize();
(2) Calculate your screen size
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
(3) Get your mouse position by passing mouseEvent me
int showX = me.getX();
int showY = me.getY();
(4) Turn up or turn left
if (me.getY() + popupSize.height > screenSize.height)
showY = me.getY() - popupSize.height;
if (me.getX() + popupSize.width > screenSize.width)
showX = me.getX() - popupSize.width;
popup.show(me.getComponent(), showX, showY);
Help it helps and good luck.
Renee