Java GUI--Dynamically Adding Buttons to a Menu

Reply

Join Date: Jun 2005
Posts: 1
Reputation: miles11 is an unknown quantity at this point 
Solved Threads: 0
miles11 miles11 is offline Offline
Newbie Poster

Java GUI--Dynamically Adding Buttons to a Menu

 
0
  #1
Jun 15th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

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

 
0
  #2
Jun 15th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1
Reputation: flybet is an unknown quantity at this point 
Solved Threads: 0
flybet flybet is offline Offline
Newbie Poster

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

 
0
  #3
Jun 16th, 2005
use jbuilder, i am a newer,readed some paper,i think jbuilder is a basic for who want the gui design.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC