Hide a button from Layout in Java Swing

前端 未结 4 1874
小蘑菇
小蘑菇 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条回答
  •  Happy的楠姐
    2020-12-18 15:51

    I see two possibilities:

    • Write your own layout manager that listens for changes to its children's visible property - shouldn't be too hard, you can probably subclass FlowLayout to do it.
    • actually remove the clicked-button from the panel and, if necessary, re-add it later.

提交回复
热议问题