• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamically adding buttons in jframe

 
tajinder pal singh
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,


Am trying to add buttons dynamically in a new Jpanel on click of a button.
i am getting new Jpanel but not able to see the buttons.






prepareHandsForGuiCode is





Am i skipping something ?
PLease advice . THanks
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you add components to a visible GUI the basic code is:



So in in your case you would add all the components to the panel in the loop and then after the loop is finished executing you would do the revalidate() and repaint().
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But why do you want to add things? The display will gradually become more and more crowded. If you want buttons to appear and disappear find out about card layout.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!