Popmenu Problem

Discussion in 'Java' started by news, Jul 26, 2003.

  1. news

    news Guest

    Hi All

    I have created a JPopupMenu to popup at right mouse click on JTextPane. The
    JPopupMenu has JCheckBoxMenuItem as its components. My problem is that the
    popup menu is not showing up over the JTextPane. I am getting its view only
    on click at the right end side of the pane. Click on other areas of the pane
    is not showing the popup. It seems to be hidden under the pane.I tried
    JPopupMenu.setLightweightpropertyEnabled(false), but even then i am not
    getting it on top. Pls. do give me a solution.

    Thanks in Advance.



    Bye

    Jimmy
    news, Jul 26, 2003
    #1
    1. Advertising

  2. news

    Roedy Green Guest

    On Sat, 26 Jul 2003 09:15:46 +0200, "news" <>
    wrote or quoted :

    > Click on other areas of the pane
    >is not showing the popup.


    If indeed the popup in hiding underneath this won't help. However, if
    it is simply not showing up trapping the click in three places may
    help:

    private void hookRightClickListener()
    {
    MouseListener newRightClickListener = new MouseAdapter()
    {
    /**
    * Invoked when a mouse button has been pressed on node in
    the Jtree
    */
    public void mousePressed( MouseEvent e )
    {
    handleRightClick( e );
    }
    /**
    * Invoked when a mouse button has been released on node in
    the Jtree
    */
    public void mouseReleased( MouseEvent e )
    {
    handleRightClick( e );
    }
    /**

    * Invoked when a mouse button has been clicked on node in the
    Jtree
    */
    public void mouseClickedd( MouseEvent e )
    {
    handleRightClick( e );
    }
    }; // end anonymous MouseAdapter

    // attach the MouseAdapter to the jtree
    jtree.addMouseListener( newRightClickListener );
    } // end hookRightClickListener

    private void handleRightClick( MouseEvent e )
    {

    // if not considered a popup trigger, e.g. right click, ignore
    it
    if ( ! e.isPopupTrigger() )
    {
    return;
    }
    ...
    rootpopup.show( e.getComponent(), e.getX(), e.getY() );
    }
    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 26, 2003
    #2
    1. Advertising

  3. news wrote:
    > Hi All
    >
    > I have created a JPopupMenu to popup at right mouse click on JTextPane. The
    > JPopupMenu has JCheckBoxMenuItem as its components. My problem is that the
    > popup menu is not showing up over the JTextPane. I am getting its view only
    > on click at the right end side of the pane. Click on other areas of the pane
    > is not showing the popup. It seems to be hidden under the pane.I tried
    > JPopupMenu.setLightweightpropertyEnabled(false), but even then i am not
    > getting it on top. Pls. do give me a solution.


    My guess is that the popupmenu appears in the upper left corner. Try
    this in your mouselisteners mouseclicked method, where menu is the popup
    menu, and thePane is your JTextPane:

    if (e.getButton() == MouseEvent.BUTTON3) {
    Point p = e.getPoint();
    menu.show(thePane, p.x, p.y);
    }

    --
    Daniel Sjöblom
    =?ISO-8859-1?Q?Daniel_Sj=F6blom?=, Jul 26, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Suurkuusk
    Replies:
    0
    Views:
    3,952
    Andreas Suurkuusk
    Jul 27, 2003
  2. Ted Miller
    Replies:
    0
    Views:
    5,139
    Ted Miller
    Sep 13, 2003
  3. Merek
    Replies:
    0
    Views:
    1,945
    Merek
    Dec 3, 2003
  4. Scott Meddows
    Replies:
    1
    Views:
    381
    John Saunders
    Jun 8, 2004
  5. Mike

    Problem problem problem :( Need Help

    Mike, May 7, 2004, in forum: ASP General
    Replies:
    2
    Views:
    534
    Bullschmidt
    May 11, 2004
Loading...

Share This Page