请问为什么会这样,
public class MyCanvas extends Canvas {
private static final long serialVersionUID = 1L;
MyFrame aFrame;
Point starPoint=null,endPoint=null;
public MyCanvas( MyFrame aFrame) {
// TODO Auto-generated constructor stub
this.aFrame=aFrame;
}
public void paint(Graphics g){
super.paint(g);
if(aFrame.DrawModen)
{ if(aFrame.Mystyle=="Point")
{
g.setColor(Color.RED);
g.drawLine(50,50, 50, 50);
g.drawLine(60,60, 60, 60);
g.drawLine(70,70, 70, 70);
g.drawLine(80,80, 80, 80);
}
if(aFrame.Mystyle=="Line")
{
g.setColor(Color.RED);
g.drawLine(50,50, 50, 80);
}
if (aFrame.Mystyle=="Rect")
{
// g.drawOval(50, 50, 100, 100); // 空心
g.drawRect(50, 50, 100, 100);
}
if (aFrame.Mystyle=="Eclipse")
{
g.drawOval(80, 40, 180, 100);
}
if (aFrame.Mystyle=="Ploy")
{
g.drawLine(50,50, 50, 80);
g.drawLine(50,80, 110, 110);
g.drawLine(110,110, 50,50);
}
}
else {
if(aFrame.Mystyle=="Point"&&starPoint!=null)
{
g.setColor(Color.red);
g.drawLine(starPoint.x, starPoint.y, starPoint.x, starPoint.y);
}
if(aFrame.Mystyle=="Line")
{
}
if (aFrame.Mystyle=="Rect")
{
}
}
}
}
------解决思路----------------------
调用一次repeat()看看