public class SimpleFrameTest implements ComponentListener
{
public void componentMoved(ComponentEvent e) {
Component c = e.getComponent();
Point p = c.getLocation();
System.out.println("Component moved to (" + p.x + ", "
+ p.y + ")");
}
public void componentResized(ComponentEvent e) {
Component c = e.getComponent();
Dimension d = c.getSize();
System.out.println("Component resized: width " + d.width +
", height " + d.height);
}
public void componentShown(ComponentEvent e) {
System.out.println("Component made visible");
}
public void componentHidden(ComponentEvent e) {
System.out.println("Component made invisible");
}
public static void main(String[] args)
{
JFrame f = new JFrame("Simple frame test");
f.setSize(300, 200);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
System.exit(0);
}
});
f.setVisible(true);
f.setResizable(false);
try {
Thread.sleep(5000); // Delay a bit
f.getContentPane().setLayout(null);
Thread.sleep(5000); // Delay a bit
f.setSize(100, 100); // Change size
Thread.sleep(5000); // Delay a bit
f.setSize(200, 200); // Move ourselves
Thread.sleep(5000); // Delay a bit
Thread.sleep(5000); // Delay a bit
f.setSize(300, 400); // Move ourselves
Thread.sleep(5000); // Delay a bit
f.setSize(600, 600); // Change size
Thread.sleep(5000); // Delay a bit
f.setSize(800, 800);
public class SimpleFrameTest implements ComponentListener
{
public void componentMoved(ComponentEvent e) {
Component c = e.getComponent();
Point p = c.getLocation();
System.out.println("Component moved to (" + p.x + ", "
+ p.y + ")");
}
public void componentResized(ComponentEvent e) {
Component c = e.getComponent();
Dimension d = c.getSize();
System.out.println("Component resized: width " + d.width +
", height " + d.height);
}
public void componentShown(ComponentEvent e) {
System.out.println("Component made visible");
}
public void componentHidden(ComponentEvent e) {
System.out.println("Component made invisible");
}
public static void main(String[] args)
{
JFrame f = new JFrame("Simple frame test");
f.setSize(300, 200);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
System.exit(0);
}
});
f.setVisible(true);
f.setResizable(false);
try {
Thread.sleep(5000); // Delay a bit
f.getContentPane().setLayout(null);
Thread.sleep(5000); // Delay a bit
f.setSize(100, 100); // Change size
Thread.sleep(5000); // Delay a bit
f.setSize(200, 200); // Move ourselves
Thread.sleep(5000); // Delay a bit
Thread.sleep(5000); // Delay a bit
f.setSize(300, 400); // Move ourselves
Thread.sleep(5000); // Delay a bit
f.setSize(600, 600); // Change size
Thread.sleep(5000); // Delay a bit
f.setSize(800, 800);