这是我用java画的一个矩形图出现了以下问题:
1、鼠标移进绘图的地方,会慕名基秒的出了一条横线来
2、每次窗口进行最大化or最小化后...这些小矩形都会自动的相前或相后移动请问是怎么回事 代码如下:import javax.swing.*;
import java.awt.*;public class linke extends JFrame{
int xx=0;
int yy=0;
public linke()
{
this.getContentPane().setBackground(Color.BLACK);
this.setUndecorated(true);
this.setSize(600,600);
this.setLocation(50,50);
this.setVisible(true);
}
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.WHITE);
for(int c=1;c<32;c++){
xx=0;
for(int i=1;i<97;i++){
if(i%6 == 0 && i!=0){
g.setColor(Color.BLACK);
}else{
g.setColor(Color.WHITE);
}
g.fill3DRect(xx, yy, 5, 5, true);
xx=xx+5;
}
yy=yy+5;
}
}
public static void main(String args[]){
linke l = new linke();
l.setBackground(Color.RED);
l.validate();
}}
1、鼠标移进绘图的地方,会慕名基秒的出了一条横线来
2、每次窗口进行最大化or最小化后...这些小矩形都会自动的相前或相后移动请问是怎么回事 代码如下:import javax.swing.*;
import java.awt.*;public class linke extends JFrame{
int xx=0;
int yy=0;
public linke()
{
this.getContentPane().setBackground(Color.BLACK);
this.setUndecorated(true);
this.setSize(600,600);
this.setLocation(50,50);
this.setVisible(true);
}
public void paint(Graphics g){
super.paint(g);
g.setColor(Color.WHITE);
for(int c=1;c<32;c++){
xx=0;
for(int i=1;i<97;i++){
if(i%6 == 0 && i!=0){
g.setColor(Color.BLACK);
}else{
g.setColor(Color.WHITE);
}
g.fill3DRect(xx, yy, 5, 5, true);
xx=xx+5;
}
yy=yy+5;
}
}
public static void main(String args[]){
linke l = new linke();
l.setBackground(Color.RED);
l.validate();
}}
第二个问题:每次最小化之后还原 图形移动那是因为你每次y的坐标从0一直增长5~