import java.awt.Component; import java.awt.Dimension; import java.awt.Frame; import java.awt.Graphics; import java.awt.ScrollPane; import java.awt.Window; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class Window1AWT { public static void main(String[] args) { Frame frame = new Frame("AWT Window"); frame.setSize(300, 200); // width, height ScrollPane scrollpane = new ScrollPane(); // Put the scrollpane into the frame. frame.add(scrollpane); // Put a big, black circle into the scrollpane. scrollpane.add(new BigBlackCircle()); frame.addWindowListener(new WindowCloser()); frame.setVisible(true); } } class BigBlackCircle extends Component { public void paint(Graphics g) { g.fillOval(0, 0, 400, 400); } public Dimension getPreferredSize() { return new Dimension(400, 400); } } class WindowCloser extends WindowAdapter { public void windowClosing(WindowEvent e) { Window window = e.getWindow(); window.dispose(); } }