home *** CD-ROM | disk | FTP | other *** search
/ Learn Java Now / Learn_Java_Now_Microsoft_1996.iso / JavaNow / Code / Chap17 / DialogWindow / AutoDialog.class (.txt) next >
Encoding:
Java Class File  |  1996-07-29  |  2.6 KB  |  72 lines

  1. import java.awt.Button;
  2. import java.awt.Checkbox;
  3. import java.awt.Container;
  4. import java.awt.Dimension;
  5. import java.awt.Font;
  6. import java.awt.Insets;
  7. import java.awt.Label;
  8. import java.awt.TextField;
  9.  
  10. public class AutoDialog {
  11.    Container m_Parent;
  12.    boolean m_fInitialized;
  13.    DialogLayout m_Layout;
  14.    Button IDOK;
  15.    Button IDCANCEL;
  16.    TextField IDC_EDIT1;
  17.    TextField IDC_EDIT2;
  18.    Label IDC_STATIC1;
  19.    Label IDC_STATIC2;
  20.    Checkbox IDC_CHECK1;
  21.  
  22.    public boolean CreateControls() {
  23.       if (!this.m_fInitialized && this.m_Parent != null) {
  24.          if (!(this.m_Parent instanceof Container)) {
  25.             return false;
  26.          } else {
  27.             Font OldFnt = this.m_Parent.getFont();
  28.             if (OldFnt != null) {
  29.                Font NewFnt = new Font(OldFnt.getName(), OldFnt.getStyle(), 14);
  30.                this.m_Parent.setFont(NewFnt);
  31.             }
  32.  
  33.             this.m_Layout = new DialogLayout(this.m_Parent, 186, 79);
  34.             this.m_Parent.setLayout(this.m_Layout);
  35.             this.m_Parent.addNotify();
  36.             Dimension size = this.m_Layout.getDialogSize();
  37.             Insets insets = this.m_Parent.insets();
  38.             this.m_Parent.resize(insets.left + size.width + insets.right, insets.top + size.height + insets.bottom);
  39.             this.IDOK = new Button("OK");
  40.             this.m_Parent.add(this.IDOK);
  41.             this.m_Layout.setShape(this.IDOK, 129, 7, 50, 14);
  42.             this.IDCANCEL = new Button("Cancel");
  43.             this.m_Parent.add(this.IDCANCEL);
  44.             this.m_Layout.setShape(this.IDCANCEL, 129, 24, 50, 14);
  45.             this.IDC_EDIT1 = new TextField("");
  46.             this.m_Parent.add(this.IDC_EDIT1);
  47.             this.m_Layout.setShape(this.IDC_EDIT1, 58, 13, 62, 14);
  48.             this.IDC_EDIT2 = new TextField("");
  49.             this.m_Parent.add(this.IDC_EDIT2);
  50.             this.m_Layout.setShape(this.IDC_EDIT2, 58, 35, 62, 14);
  51.             this.IDC_STATIC1 = new Label("First Name:", 0);
  52.             this.m_Parent.add(this.IDC_STATIC1);
  53.             this.m_Layout.setShape(this.IDC_STATIC1, 13, 13, 41, 8);
  54.             this.IDC_STATIC2 = new Label("Last Name:", 0);
  55.             this.m_Parent.add(this.IDC_STATIC2);
  56.             this.m_Layout.setShape(this.IDC_STATIC2, 13, 37, 40, 8);
  57.             this.IDC_CHECK1 = new Checkbox("Married");
  58.             this.m_Parent.add(this.IDC_CHECK1);
  59.             this.m_Layout.setShape(this.IDC_CHECK1, 59, 55, 39, 10);
  60.             this.m_fInitialized = true;
  61.             return true;
  62.          }
  63.       } else {
  64.          return false;
  65.       }
  66.    }
  67.  
  68.    public AutoDialog(Container parent) {
  69.       this.m_Parent = parent;
  70.    }
  71. }
  72.