import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class c9_1 extends JFrame{
JFrame f=new JFrame();
Container cp=f.getContentPane();
public c9_1()
{
f.setVisible(true);
f.setSize(200, 200);
this.addMouseListener(new MouseAdapter()
int x,y;
public void mousePressed(MouseEvent e)
{
x=e.getX();
y=e.getY();
}
public void mouseReleased(MouseEvent e)
{ getGraphics().setColor(Color.blue);
getGraphics().drawLine(x, y, e.getX(), e.getY());
});
}
public static void main(String[]args)
{
new c9_1();
}
}错误是这样的,Syntax error, insert "}" to complete ClassBody at c9_1.<init>(c9_1.java:14)
at c9_1.main(c9_1.java:35)
请指教
解决方案 »
- 求助:关于java通过POI操作Excel的一个问题。。。。
- 高分求解啊,大家帮帮忙啊.
- 请看看这个提示是什么意思呀。
- JDBC连接SQLServer2000问题(怎么写就是不对,我已经打了sp4)
- 用java处理并输出CSV文件的时候,如何处理需要显示的逗号和双引号?
- 关于instanceof运算符的问题
- oicq聊天机器人可以对着OICQ聊天室说个没完的家伙,据作者说,测试时有人不知道是程序,居然跟它聊
- java 能不能取出某个class的所有的method ? 在线等
- java 高手请进
- Join our project (based on open source)
- ArrayList 的remove方法
- 关于this的用法。。一个小问题啊。。
import java.awt.event.*;
import javax.swing.*;
public class c9_1 extends JFrame{
JFrame f=new JFrame();
Container cp=f.getContentPane();
public c9_1()
{
f.setVisible(true);
f.setSize(200, 200);
this.addMouseListener(new MouseAdapter()
int x,y;
public void mousePressed(MouseEvent e)
{
x=e.getX();
y=e.getY();
}
public void mouseReleased(MouseEvent e)
{ getGraphics().setColor(Color.blue);
getGraphics().drawLine(x, y, e.getX(), e.getY());
});
}
public static void main(String[]args)
{
new c9_1();
}
}
刚刚程序没贴好
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class c9_1 extends JFrame{
JFrame f=new JFrame();
Container cp=f.getContentPane();
public c9_1()
{
f.setVisible(true);
f.setSize(200, 200);
this.addMouseListener(new MouseAdapter()
int x,y;
public void mousePressed(MouseEvent e)
{
x=e.getX();
y=e.getY();
}
public void mouseReleased(MouseEvent e)
{ getGraphics().setColor(Color.blue);
getGraphics().drawLine(x, y, e.getX(), e.getY());
});
}
public static void main(String[]args)
{
new c9_1();
}
}
//actions
});鼠标事件 这么改下
this.addMouseListener(new MouseAdapter(){//这里要加一个大括号
int x,y;
public void mousePressed(MouseEvent e)
{ x=e.getX();
y=e.getY();
}
public void mouseReleased(MouseEvent e)
{ getGraphics().setColor(Color.blue);
getGraphics().drawLine(x, y, e.getX(), e.getY()); }
}//这里也要加还有同意五楼的