展开全部
JOptionPane.showMessageDialog("null", "你的输入不合法!");
这种方法e68a843231313335323631343130323136353331333330333035是swing里面的 如果用awt里面的方法其实是dialog d = new dialog(f,"提示信息“,true)f表示的是这个对话框是哪个窗体错误时的弹出对话框,true表示的是如果这个弹出对话框不关闭则不能对frame进行操作, 在 d里面再加一个label表示你要提示的信息。给你贴一段代码
but.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String text = tf.getText();
tf.setText("");
File file = new File(text);
if(file.exists() && file.isDirectory()){//--------->两种遍历方法。。。记下来吧都
ta.setText("");
/*String[] names = file.list();
for (String name : names) {
ta.append(name + "\r\n");
}*/
traverse(file);
}
else{
String msg = "您输入的" + text +"有误