JFrame resizable height ONLY

后端 未结 7 1476
我在风中等你
我在风中等你 2020-12-15 13:16

JFrame.setResizable(true) lets the user resize both the width and height of a window. Does a method exist which allows the user to ONLY resize the height?

相关标签:
7条回答
  • 2020-12-15 13:40

    To avoid flickering, you can override #setBounds method in your JFrame. Seems like every resize will call it. Something like

    @Override
    public void setBounds(int x, int y, int width, int height) {
        if (width == FIXED_WIDTH) {
            super.setBounds(x, y, width, height);
        }
    }
    

    did the trick for me.

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