swing写 paint,后窗口一片空白

我曾将paint(Graphics g) 写为 paintmap(Graphics g,int mapx) 但发现,重写后窗口一片空白

后来发现原因是,我重写的paintmap(g,mapx) 先绘图执行,然后系统再调用了paint(g) 绘图,但这个绘图使窗口重绘

覆盖了我想要的图,。

我的解决方法是重写paint(Graphics g){

                                paintmap(Graphics g,int mapx);// 调用

                              } // 让paint 执行我要的函数

repaint( )方法会调用其对象的paint() 方法,其g默认是其对象


猜你喜欢

转载自blog.csdn.net/qq_38966984/article/details/79692977