(sorry for the bad format)
编译时报错:第38行“不是语句”
第38行需要".class"[code=java]import java.awt.*;
import java.awt.event.*;
import java.io.*;
class L
{
private Frame f;
private Button b;
private TextField tf;
private TextArea ta;
public void init()
{
f=new Frame();
f.setBounds(110,200,400,300);
f.setLayout(new FlowLayout());
tf=new TextField(30);
b=new Button("转到");
ta=new TextArea(33,40);
f.add(tf);
f.add(b);
f.add(ta);
myEvent();
f.setVisible(true);
}
public void myEvent()
{
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(dir.exists()&&dir.isDirectory())
String dirPath=tf.getText();
File dir=new File(dirPath);
String[] names=dir.list();
for(String name:names)
{
System.out.println(name);
}
ta.setText(text);
tf.setText("");
}
});
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent a)
{
System.exit(0);
}
});
}
public static void main(String args[])
{
L l=new L();
l.init();
}
}[/code]
[ 本帖最后由 黑马李刚 于 2011-09-09 20:02 编辑 ] |