Results 1 to 2 of 2
  1. #1
    jperson is offline Member
    Join Date
    Jan 2010
    Posts
    61
    Rep Power
    0

    Default scroll popupmenu

    i make this code to let the user to choose item using popup menu


    Java 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 ?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default

    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)
    Java 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

Similar Threads

  1. smooth-scroll
    By designer in forum Java Applets
    Replies: 1
    Last Post: 07-21-2009, 08:10 PM
  2. Scroll message
    By getkiran in forum Java Applets
    Replies: 1
    Last Post: 03-05-2009, 05:29 AM
  3. Hello!! I need to add a popupMenu to a menu
    By andr33i_yo in forum AWT / Swing
    Replies: 10
    Last Post: 12-30-2008, 01:22 PM
  4. various actions in menuitem of popupmenu
    By Peggy in forum Java Applets
    Replies: 0
    Last Post: 12-11-2008, 12:50 PM
  5. Jtextarea and scroll
    By ziniestro in forum AWT / Swing
    Replies: 2
    Last Post: 06-01-2007, 04:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •