1. 程式人生 > >用java 生成視窗

用java 生成視窗



import java.awt.*;
import java.awt.event.*;
public class example {
 public static void main(String[] args){
  Frame f=new Frame("mine!");
  f.setSize(400,300);
  f.setLocation(300,200);
  f.setVisible(true);
  MyWindowListener mw=new MyWindowListener();
  f.addWindowListener(mw);
 }
}
class MyWindowListener implements WindowListener{
 public void windowClosing(WindowEvent e){
  Window window=e.getWindow();
  window.setVisible(false);
  window.dispose();
 }
 public void windowActivated(WindowEvent e){
  
 }
 public void windowClosed(WindowEvent e){
  
    }
 public void windowDeactivated(WindowEvent e){
  
 }
 public void windowDeiconfied(WindowEvent e){
  
 }
 public void windowIconfied(WindowEvent e){
  
 }
 public void windowOpened(WindowEvent e){
  
 }
}