JPanel size by inner components

前端 未结 8 2221
夕颜
夕颜 2021-02-18 13:48

Is it possible to tell JPanel to set its size to fit all components that it contains? Something like pack() for JFrame.

edit: The trick with preferredSize d

8条回答
  •  时光说笑
    2021-02-18 14:53

    maybe you can do something like that by removing from your panel

    setResizable(false);

提交回复
热议问题