The Artima Developer Community
Sponsored Link

Java Answers Forum
Adding JMenu To a Jbutton

2 replies on 1 page. Most recent reply: Jul 1, 2005 5:07 AM by Collin Garymore

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Collin Garymore

Posts: 22
Nickname: callan
Registered: Jan, 2005

Adding JMenu To a Jbutton Posted: Jun 30, 2005 4:24 AM
Reply to this message Reply
Advertisement
Hi to every one,

I would like some Help please.
I wonder How to add a Menu to a Button that works. I did it, but does not work at all.
Please could someone gives some little tips?
JButton advancedB = new JButton ( " Advanced " );
    JMenu buttonMenu = new JMenu ( " Advanced " );
        JMenuItem advanced4 = mew JMenuItem ( " << 4 " );
        JMenuItem advanced6 = mew JMenuItem ( " << 6" );
        JMenuItem advanced8 = mew JMenuItem ( " << 8" );
    buttonMenu.add ( advabced4 );
    buttonMenu.add ( advabced6 );
    buttonMenu.add ( advabced8 );
advanceB.add ( buttonMenu );

Many Thanks All.


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Adding JMenu To a Jbutton Posted: Jun 30, 2005 8:37 AM
Reply to this message Reply
Now I'm wondering what you want to accomplish ...

Do you try to show a PopupMenu?
Then use JPopupMenu.
The PopupMenu is not "added" to a button but usually shown when you click the button.

Collin Garymore

Posts: 22
Nickname: callan
Registered: Jan, 2005

Re: Adding JMenu To a Jbutton Posted: Jul 1, 2005 5:07 AM
Reply to this message Reply
Matthias, I think that you're the coolest guy on this forhum.

I thought of JPopupMenu, and find some examples on java.sun.com's forum. It's working fine this morning.

Many thanks for your attention,
Best wishes for your future.
Collin.

PS:

http://forum.java.sun.com/thread.jspa?forumID=256&threadID=404764

In case some one would like to have a copy...

Flat View: This topic has 2 replies on 1 page
Topic: create index or key with jackcess Previous Topic   Next Topic Topic: JAVA PROJECT INSTALLATION SETUP.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use