Results 1 to 4 of 4

Thread: popup menu

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

    Default popup menu

    i made a simple code to make JFrame and add popup menu to it
    when i clicked on the menu item, popup menu become invisible

    Java Code:
    public static void main(String[] args) {
            JFrame f = new JFrame();
            f.setSize(400, 500);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setLocationRelativeTo(null);
            JPopupMenu p = new JPopupMenu("x");
            p.add(new JMenuItem("new"));
            p.add(new JMenuItem("cut"));
            f.show();
            p.show(f, 50, 50);
    
        }
    what's the problem ?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Quote Originally Posted by jperson View Post
    when i clicked on the menu item, popup menu become invisible

    what's the problem ?
    Yes, what is your problem? That's the normal behavior of menus in all platforms, not just in Java.

    Explain your requirement better.

    db

  3. #3
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    i think, instead of making the popup menus show initially there, you might want to have an event handler on the main window, such as a mouse click event , or a main menu, to cause the popup menus to be displayed,?

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    I should have looked at this one's posting history before trying to help. jperson has a habit of not returning to the threads it started.

    db

Similar Threads

  1. tray popup menu
    By newbiejava in forum New To Java
    Replies: 1
    Last Post: 01-11-2010, 07:05 PM
  2. js popup menu problem
    By webdreamer in forum New To Java
    Replies: 2
    Last Post: 11-16-2009, 08:50 PM
  3. How can I add popUp menu on a tab of a tabbedPane?
    By shahid0627 in forum AWT / Swing
    Replies: 1
    Last Post: 08-31-2009, 04:19 AM
  4. add PopUp menu by NetBeans
    By hungleon88 in forum AWT / Swing
    Replies: 1
    Last Post: 09-12-2008, 01:05 PM
  5. Replies: 7
    Last Post: 05-09-2008, 07:54 AM

Posting Permissions

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