一个菜鸟问题:帮我看看这个关于“关闭窗口按钮”的问题吧!谢谢! Action d = new AbstractAction("exit") { public void actionPerformed(ActionEvent event) { System.exit(0); } };不能直接这样写 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.io.*; class exceptiondemo{ public static void main(String args[])throws IOException { FileInputStream fis = null; try { System.out.println("first argument is "+args[0]); fis = new FileInputStream("text.txt"); System.out.println("content of text is :"); int b; while((b=fis.read())!= -1) { System.out.print((char)b); } } catch(FileNotFoundException e) { System.out.println(e); } catch(IOException e) { System.out.println(e); } catch(IndexOutOfBoundsException e) { System.out.println("closing fileinputstream.."); } finally { if (fis != null) { fis.close(); } else { System.out.println("fileinputstream not open"); } } }} 因为你的变量d被用了两次,一次是:d=new Button("close");另一次是:Action d = new AbstractAction("exit")而f.add(d,BorderLayout.EAST);这里面的d应该是个Component,而不是Action.你需要把变量名换一换. 在哪里可以下载到linux的jdk 急!!! 求助!两个没有编译错误实现同样功能的程序,但实现结果不一样! Applet的getAppletContext().showDocument()参数隐藏问题 Socket题目,真正的高手请赐教,谢谢 使用java的cp功能出现如下错误 例子看不懂了,为什么会出现象下面这样的对象创建方式? eclipse的问题(关于swt) 请大家帮忙看看 初学者的问题大家帮忙呀!!谢谢了 构造器里调用构造器的问题 高分求jface的资料 关闭窗口
class exceptiondemo
{
public static void main(String args[])throws IOException
{
FileInputStream fis = null;
try
{
System.out.println("first argument is "+args[0]);
fis = new FileInputStream("text.txt");
System.out.println("content of text is :");
int b;
while((b=fis.read())!= -1)
{
System.out.print((char)b);
}
}
catch(FileNotFoundException e)
{
System.out.println(e);
}
catch(IOException e)
{
System.out.println(e);
}
catch(IndexOutOfBoundsException e)
{
System.out.println("closing fileinputstream..");
}
finally
{
if (fis != null)
{
fis.close();
}
else
{
System.out.println("fileinputstream not open");
}
}
}
}
一次是:d=new Button("close");另一次是:Action d = new AbstractAction("exit")而f.add(d,BorderLayout.EAST);这里面的d应该是个Component,而不是Action.你需要把变量名换一换.