Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamically adding buttons in jframe  RSS feed

 
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: 2752
11
  • 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
Sheriff
Posts: 53720
127
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!