Automatically size JPanel inside JFrame

前端 未结 5 1866
我寻月下人不归
我寻月下人不归 2020-12-10 04:23

I have a JPanel subclass on which I add buttons, labels, tables, etc. To show on screen it I use JFrame:

MainPanel mainPanel = new          


        
5条回答
  •  一整个雨季
    2020-12-10 05:07

    If the BorderLayout option provided by our friends doesnot work, try adding ComponentListerner to the JFrame and implement the componentResized(event) method. When the JFrame object will be resized, this method will be called. So if you write the the code to set the size of the JPanel in this method, you will achieve the intended result.

    Ya, I know this 'solution' is not good but use it as a safety net. ;)

提交回复
热议问题