java编程问题, 30
java编程问题,publicclaasTest2{JFrameframe;frame=newJFrame();frame.setBounds(300,300,300,3...
java编程问题,public claas Test2{
JFrame frame;
frame=new JFrame();
frame.setBounds(300,300,300,300);
frame.setVisible(true);
frame.addMouseMotionListener(new MouseMotionAdapter(){
public void mouseMoved(MouseEvent me){
frame.repaint();
Graphics g=frame.getGraphics();
for(int i=0;i<=10;i++)
g.drawString("hello",me.getX(),me.getY());
}
});
}
public static void main(String[] agrs){
new Test2().myframe();
}
}}
代码运行后,鼠标移进窗口,hello字符不断闪烁,之后消失,请问为什么会消失掉?drawString()调用之后并没有调用repaint()啊。???高手请指点,感激不尽! 展开
JFrame frame;
frame=new JFrame();
frame.setBounds(300,300,300,300);
frame.setVisible(true);
frame.addMouseMotionListener(new MouseMotionAdapter(){
public void mouseMoved(MouseEvent me){
frame.repaint();
Graphics g=frame.getGraphics();
for(int i=0;i<=10;i++)
g.drawString("hello",me.getX(),me.getY());
}
});
}
public static void main(String[] agrs){
new Test2().myframe();
}
}}
代码运行后,鼠标移进窗口,hello字符不断闪烁,之后消失,请问为什么会消失掉?drawString()调用之后并没有调用repaint()啊。???高手请指点,感激不尽! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询