在php中很少涉及GUI,资料也非常少,官方有一些说明
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
}
}



Comment:


