Dynamically Add Components to a JDialog

前端 未结 3 1482
时光说笑
时光说笑 2020-11-22 12:28

I am having trouble adding JComponents to a JDialog when the user clicks a button on the JDialog. Basically I want it to look like this:

3条回答
  •  孤独总比滥情好
    2020-11-22 13:05

    When dynamically adding/removing components from a container, it's necessary to invoke revalidate()/validate() and repaint() afterward. The former will force the container to layout its components again and the latter will remove any visual "artifacts".

提交回复
热议问题