分类:java share 发布 2009.05.03 22:05:12Tag : java,php,addWindowListener commentComment:0
7
dig bury

在php中很少涉及GUI,资料也非常少,官方有一些说明

http://gtk.php.net/

java

public class TestFrame implements ActionListener {

 /**
  * @param args
  */
 Frame f = new Frame("test");

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  TestFrame tf = new TestFrame();
  tf.init();

 }

 public void init() {
  Button btn = new Button("ok");
  f.add(btn);
  btn.addActionListener(this);
  f.setSize(300, 300);
  f.setVisible(true);
  f.addWindowListener(new MyWindowListener());
 }

 public void actionPerformed(ActionEvent e) {
  //f.doLayout();
  //System.exit(0);
 }
}
import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class MyWindowListener implements WindowListener{

 
 public void windowActivated(WindowEvent e) {
  // TODO Auto-generated method stub
  
 }
 public void windowClosed(WindowEvent e) {
  // TODO Auto-generated method stub
  
 }
 public void windowClosing(WindowEvent e) {
  // TODO Auto-generated method stub
  e.getWindow().setVisible(false);
  ((Window)e.getComponent()).dispose();
  System.exit(0);
 }
 public void windowDeactivated(WindowEvent e) {
  // TODO Auto-generated method stub
  
 }
 public void windowDeiconified(WindowEvent e) {
  // TODO Auto-generated method stub
  
 }
 public void windowIconified(WindowEvent e) {
  // TODO Auto-generated method stub
  
 }
 public void windowOpened(WindowEvent e) {
  // TODO Auto-generated method stub
  
 }

}
 

我也来说2句,请不要发表违反法律的言论

姓名

Email(必填)

主页(不要加http://)