FileDocCategorySizeDatePackage
CoordinatesDemo.javaAPI DocExample2969Tue Dec 12 18:59:04 GMT 2000None

CoordinatesDemo

public class CoordinatesDemo extends JApplet

Fields Summary
JLabel
label
Constructors Summary
Methods Summary
voidbuildUI(java.awt.Container container)

        container.setLayout(new BoxLayout(container,
                                          BoxLayout.Y_AXIS));

        CoordinateArea coordinateArea = new CoordinateArea(this);
        container.add(coordinateArea);

        label = new JLabel("Click within the framed area.");
        container.add(label);

        //Align the left edges of the components.
        coordinateArea.setAlignmentX(LEFT_ALIGNMENT);
        label.setAlignmentX(LEFT_ALIGNMENT); //redundant
    
public voidinit()

        buildUI(getContentPane());
    
public static voidmain(java.lang.String[] args)

        JFrame f = new JFrame("CoordinatesDemo");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        CoordinatesDemo controller = new CoordinatesDemo();
        controller.buildUI(f.getContentPane());
        f.pack();
        f.setVisible(true);
    
public voidupdateLabel(java.awt.Point point)

        label.setText("Click occurred at coordinate ("
                      + point.x + ", " + point.y + ").");