去掉:
package MarathonApp;
package MarathonApp;
解决方案 »
- 关于把内部类写在外部类的外部的一个问题 相当于两个类之间的调用问题 请高手指教
- ResourceBundle问题
- socket.......java.lang.NullPointerException
- 高手请围观一个例子
- 求助:java中有没有类似vb中的Tab控件?
- 关于类实现接口的问题,这句话我不明白。
- 那个函数可以实现Double数的四舍五入
- ★大侠帮忙★一个简单的问题★
- 帮忙基于TCP/IP协议的文件传输编程!!!!!!!!!!!!!!!!!!!(((((急)))))
- 哪位大哥可以整理一下javamail的有关问题吗,我愿意以分相赠
- 如何判断ftp server端当前是否Action?
- 怎样用java调用DLL动态连接库?
onApp.MarathonApp 中定义windowOpened(java.awt.event.WindowEvent)
public class MarathonApp implements WindowListener
^
1 个错误声明卖windowOpened接口的实现吧
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;public class MarathonApp
{
JLabel label = new JLabel("It just keeps going,and going...");
JFrame frame = new JFrame("MarathonApp Example"); public MarathonApp()
{
frame.getContentPane().add (label);
frame.setSize(300,100);
frame.setVisible (true);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit (0);
}
});
frame.show();
}
public static void main(String[] args)
{
MarathonApp m = new MarathonApp();
}}
interface WindowListener共有7个方法,所以在你的程序中再加入以下6个方法就可以了。
public void windowOpened(WindowEvent e){
}
public void windowClosed(WindowEvent e){
}
public void windowIconified(WindowEvent e){
}
public void windowDeiconified(WindowEvent e){
}
public void windowActivated(WindowEvent e){
}
public void windowDeactivated(WindowEvent e){
}
可以查看Thinking in Java(version 1) chapter13的 Using listener adapters for simplicity小节
... But since WindowListener is an interface, you must implement all of the other methods even if they don’t do anything. This can be annoying.
To solve the problem, each of the listener interfaces that have more than one method are provided with adapters,...