944,137 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 5209
  • Java RSS
Jun 15th, 2005
0

Java GUI--Dynamically Adding Buttons to a Menu

Expand Post »
Hi All--
I basically am trying to write a piece a piece of code for an application that will list all the open frames in the program, and if you click one, it is selected and brought to the top of the program. I have a menu bar, and I want to be able to select a Menu from it, and then have that menu drop down and list all the open frames.
The problem is I have to gather the open frames whenever I click the menu, and so I have to dynamically create buttons, corresponding to an arbitrary amount of frames which might be open.
Getting a list of the components is not difficult, and creating buttons doesn't seem to be. I just go through a for loop of all the open components, creating buttons, within a mouse listener. But it won't let me insert these buttons into the menu unless the menu is final (which it can't be since it should be dynamic).

Any ideas?

Thanks,
Miles
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
miles11 is offline Offline
1 posts
since Jun 2005
Jun 15th, 2005
0

Re: Java GUI--Dynamically Adding Buttons to a Menu

You should be able to easily do this with add() or remove(). Are you remembering that a Menu must have JMenuItems and not buttons? Also, if your getting an error, post it.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Jun 16th, 2005
0

Re: Java GUI--Dynamically Adding Buttons to a Menu

use jbuilder, i am a newer,readed some paper,i think jbuilder is a basic for who want the gui design.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
flybet is offline Offline
1 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC