adding components dynamically in a JPanel

前端 未结 2 958
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-06 15:13

how can i add components dynamically in a jpanel? I am having add button when i click the button the components should be added to the JPanel.

my question is that ad

2条回答
  •  无人及你
    2020-12-06 16:04

    Just as you always do, except that you have to call:

    panel.revalidate();
    

    when you are done, since the container is already realized.

提交回复
热议问题