Hide a button from Layout in Java Swing

前端 未结 4 1889
小蘑菇
小蘑菇 2020-12-18 15:04

I am trying something very basic: I have a list of 5 buttons. They are in a FlowLayout and the general idea should be that once I click one it should disappear and the other

4条回答
  •  情话喂你
    2020-12-18 15:39

    You could override each button's getPreferredSize() methods (and possibly getMinimumSize() as well to return 0,0 when the component is invisible; and you need to call, I think, invalidate() (or revalidate or validate, I can never keep them straight) on the container.

提交回复
热议问题