FileDocCategorySizeDatePackage
InfoDialog.javaAPI DocExample2225Fri Feb 16 13:29:32 GMT 1996None

InfoDialog

public class InfoDialog extends Dialog

Fields Summary
protected Button
button
protected MultiLineLabel
label
Constructors Summary
public InfoDialog(Frame parent, String title, String message)

        // Create a dialog with the specified title
        super(parent, title, false);
        
        // Create and use a BorderLayout manager with specified margins
        this.setLayout(new BorderLayout(15, 15));
        
        // Create the message component and add it to the window
        label = new MultiLineLabel(message, 20, 20);
        this.add("Center", label);
        
        // Create an Okay button in a Panel; add the Panel to the window
        // Use a FlowLayout to center the button and give it margins.
        button = new Button("Okay");
        Panel p = new Panel();
        p.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15));
        p.add(button);
        this.add("South", p);

        // Resize the window to the preferred size of its components
        this.pack();
    
Methods Summary
public booleanaction(java.awt.Event e, java.lang.Object arg)

        if (e.target == button) {
            this.hide();
            this.dispose();
            return true;
        }
        else return false;
    
public booleangotFocus(java.awt.Event e, java.lang.Object arg)

        button.requestFocus();
        return true;
    
public static voidmain(java.lang.String[] args)

        Frame f = new Frame("InfoDialog Test");
        f.resize(100, 100);
        f.show();
        InfoDialog d = new InfoDialog(f, "Help", 
                          "The host you are trying to contact\n" +
                          "is not currently responding.\n" +
                          "Please try again later.");
        d.show();