Dynamically adding components to JPanel

前端 未结 1 402
孤独总比滥情好
孤独总比滥情好 2020-12-22 01:17

I\'m trying to dynamically add some components to a JPanel, but unfortunatelly they don\'t appear. I only see the ones added in the constuctor.

Updated version (addi

相关标签:
1条回答
  • 2020-12-22 02:01

    Call validate() on the parent container, as shown in the Nested Layout Example. Those labels on the lower left are added dynamically. Note that calling pack() might cause the size of the GUI to change, whereas calling validate() won't. If you need to get the GUI to resize - call pack(), else call validate().

    0 讨论(0)
提交回复
热议问题