import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import javax.swing.JFrame;
public class Main extends JFrame implements ComponentListener {
public Main() {
addComponentListener(this);
}
public void componentHidden(ComponentEvent e) {
System.out.println("componentHidden");
}
public void componentMoved(ComponentEvent e) {
System.out.println("componentMoved");
}
public void componentResized(ComponentEvent e) {
System.out.println("componentResized");
if (getState() == Frame.ICONIFIED) {
System.out.println("RESIZED TO ICONIFIED");
} else if (getState() == Frame.NORMAL) {
System.out.println("RESIZED TO NORMAL");
} else {
System.out.println("RESIZED TO MAXIMIZED");
}
}
public void componentShown(ComponentEvent e) {
}
public static void main(String[] arg) {
Main m = new Main();
m.setVisible(true);
m.setSize(new Dimension(300, 100));
m.setLocation(50, 50);
}
}
|