-
scroll popupmenu
i make this code to let the user to choose item using popup menu
Code:
private void jTextPane1MouseReleased(java.awt.event.MouseEvent evt) {
if (evt.getButton() == evt.BUTTON3) {
popup.getMenu().show(evt.getComponent(), evt.getX(), evt.getY());
//with no scrolling
}
}
popup object return popup menu with items , how to scrolling popup menu ?
-
First off, for cross platform compatibility you should be testing for e.isPopupTrigger() in both mousePressed and mouseReleased
MouseEvent (Java Platform SE 6))
The most common programming idiom for this is (in the MouseListener) Code:
public void mousePressed(MouseEvent e) {
maybeShowPopup(e);
}
public void mouseReleased(MouseEvent e) {
maybeShowPopup(e);
}
private void maybeShowPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
// show popup
}
}
This may be useful to you for scrolling the menu:
Menu Scroller « Java Tips Weblog
Finally, I see from the code you posted that you have used some kind of code generator. Don't. Or at least, don't use any automated means of creating a GUI until you are capable of producing the same GUI by manual coding. Which you aren't (yet), or you wouldn't be asking questions here.
db