Using popup menus

Documents for the development of and with JVx.

Using popup menus

Postby Development@SIB » Tue Oct 01, 2013 3:44 pm

If you need a popup menu for your table on right mouse click, simple add it. A short example:

Syntax: [ Download ] [ Hide ]
UIMenu menActions = new UIMenu("Actions");
                       
UIMenuItem miInsert = new UIMenuItem("Insert");
UIMenuItem miDelete = new UIMenuItem("Delete");
                       
menActions.add(miInsert);
menActions.add(miDelete);              
       
UIMenuItem  miSearch = new UIMenuItem("Show");
miSearch.setImage(UIImage.getImage(UIImage.SEARCH_SMALL));

UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.add(menActions);
popupMenu.addSeparator();
popupMenu.add(miSearch);

You should add a mouse event for your component, to show the popup (you also could add the event to an image or a panel):

Syntax: [ Download ] [ Hide ]
tblMaster.eventMousePressed().addListener(this, "doShowPopup");
 

and the listener method:

Syntax: [ Download ] [ Hide ]
public void doShowPopup(UIMouseEvent pEvent)
{
    if (pEvent.isPopupTrigger() )
    {  
        popupMenu.show(pEvent.getSource(), pEvent.getX(), pEvent.getY());
    }
}
User avatar
Development@SIB
 
Posts: 311
Joined: Mon Sep 28, 2009 1:54 pm

Return to Documentation