当前位置: 代码迷 >> Java Web开发 >> Syntax error on token "{" { expected after this token,该怎么解决
  详细解决方案

Syntax error on token "{" { expected after this token,该怎么解决

热度:4712   发布时间:2013-02-25 21:16:03.0
Syntax error on token "{", { expected after this token
我的程序老是报这样的错,我应该怎么办?急!
import java.awt.*;
import java.awt.event.*;
//import java.applet.*;
//import javax.swing.ImageIcon;
import javax.swing.*;
import java.io.*;

//画布,运行中图画部分
class Imagecanvas extends Canvas {  
private static final long serialVersionUID = 1L;//保证兼容性
Toolkit tool;//工具箱
Image Im;//图像

Imagecanvas() {
setSize(300, 50);
tool = getToolkit();//返回窗体工具包
Im = tool.getImage("dj.jpg");
}

public void paint(Graphics g) {
g.drawImage(Im, 0, 0, 150, 50, this);//在画布上g上画图片Im坐标为(0,0),Graphics.top为360,Graphics.left为50
}
}

//按钮
class GongNeng extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;

GongNeng() {
super("车辆管理");
setSize(250, 200);//大小
setLocation(250, 120);//位置
setResizable(false);//窗口大小是否可改变
JPanel p1 = new JPanel();//图片区
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();

Imagecanvas canvas1 = new Imagecanvas();
p1.setSize(300, 150);
p1.add(canvas1);

p2.setBounds(70, 70, 200, 80);
p2.setLayout(new GridLayout(2, 1, 5, 5));
JButton number = new JButton("车辆信息");
JButton create = new JButton("新建");
Container c = getContentPane();
c.setLayout(null);
  p2.add(number);
p2.add(new JLabel(" "));
p2.add(create);
   
add(BorderLayout.NORTH, p1);
add(BorderLayout.CENTER, p2);
add(BorderLayout.SOUTH, p3);
this.setVisible(true);
}
 
public void actionPerformed(ActionEvent e) {

}
}

 class BaoCun extends WindowAdapter implements ActionListener{
Frame f;
Button btn;
//TextArea ta;
String fileName;
  public class XinJian{
this.fileName=fileName;
f=new Frame();
f.addWindowListener(this);
TextField ta =new TextField(25);
btn=new Button("保存");
btn.addActionListener(this);
//ta=new TextArea(60,60);
f.add(ta,BorderLayout.CENTER);
f.add(btn,BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
//new XinJian();
}

public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals(btn)){
new XinJian();
}

}
}
public class GuanLi {
public static void main(String[] args) {
new GongNeng();
}
}
}
如果可以的话,希望能帮我弄成可执行的,我是新手,谢谢帮忙!

------解决方案--------------------------------------------------------
少了个'}'
  相关解决方案