Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Can anyone give insight as to why a JPanel that is drawing simple shapes such as rectangles, in small quantity, could lag noticeably when resizing the frame?

I think that by adding an event for window resize and timing the resize to 1/10 s or so, I could solve the problem. But I'm not so sure.

EDIT:

After reviewing the example code I found that the resize lag is due to having a handler that scales drawn objects by getting the height and width of the screen.

   this.addComponentListener(new ComponentAdapter() {
            public void componentResized(ComponentEvent e) {

                setScale( getHeight(), getWidth() );
            }
        });

Is there any way to smooth the resize lag?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
167 views
Welcome To Ask or Share your Answers For Others

1 Answer

The example cited here scales well into the thousands of nodes and edges. It may serve as a useful reference example. A profiler, for example, may also offer some insight.

image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...