How to “do something” on Swing component resizing?

后端 未结 8 1119
遇见更好的自我
遇见更好的自我 2021-01-17 07:53

I\'ve a class which extends JPanel. I overwrote protected void paintComponent(Graphics g).

There is a variable which has to be recalculate

8条回答
  •  野的像风
    2021-01-17 08:12

    Here's what I use (where CoordinatePlane is a JPanel):

    I'm not an expert

    public CoordinatePlane() {
        setBackground(Color.WHITE);
        this.addComponentListener(new ComponentAdapter(){
            public void componentResized(ComponentEvent e) {
                //YOUR CODE HERE         
            }
        });
    }
    

提交回复
热议问题