适配器模式的三种方式
第一种方式(基于继承):
package com.unis.zzg.defaultadapter;import java.awt.Frame;import java.awt.event.MouseEvent;import java.awt.event.MouseMotionAdapter;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;public class Awt {public static void main(String[] args) {Frame frame = new Frame("window");frame.addMouseMotionListener(new MouseMotionAdapter() {@Overridepublic void mouseMoved(MouseEvent e) {System.out.println("X:"+e.getX()+"Y:"+e.getY());}});frame.addWindowListener(new WindowAdapter() {@Overridepublic void windowClosing(WindowEvent e) {System.out.println("window colse");System.exit(0);}});frame.setSize(300, 300);frame.setVisible(true);}}