home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-06-13 | 3.3 KB | 110 lines |
- //------------------------------------------------------------------------------
- // AutoDialog.java:
- // Implementation for container control initialization class AutoDialog
- //
- //------------------------------------------------------------------------------
- import java.awt.*;
- import DialogLayout;
-
- public class AutoDialog
- {
- Container m_Parent = null;
- boolean m_fInitialized = false;
- DialogLayout m_Layout;
-
- // Control definitions
- //--------------------------------------------------------------------------
- Button IDOK;
- Button IDCANCEL;
- TextField IDC_EDIT1;
- TextField IDC_EDIT2;
- Label IDC_STATIC1;
- Label IDC_STATIC2;
- Checkbox IDC_CHECK1;
-
-
- // Constructor
- //--------------------------------------------------------------------------
- public AutoDialog (Container parent)
- {
- m_Parent = parent;
- }
-
- // Initialization.
- //--------------------------------------------------------------------------
- public boolean CreateControls()
- {
- // Can only init controls once
- //----------------------------------------------------------------------
- if (m_fInitialized || m_Parent == null)
- return false;
-
- // Parent must be a derivation of the Container class
- //----------------------------------------------------------------------
- if (!(m_Parent instanceof Container))
- return false;
-
- // Since there is no way to know if a given font is supported from
- // platform to platform, we only change the size of the font, and not
- // type face name. And, we only change the font if the dialog resource
- // specified a font.
- //----------------------------------------------------------------------
- if (true)
- {
- Font OldFnt = m_Parent.getFont();
- if (OldFnt != null)
- {
- Font NewFnt = new Font(OldFnt.getName(), OldFnt.getStyle(), 14);
-
- m_Parent.setFont(NewFnt);
- }
- }
-
- // All position and sizes are in Dialog Units, so, we use the
- // DialogLayout manager.
- //----------------------------------------------------------------------
- m_Layout = new DialogLayout(m_Parent, 186, 79);
- m_Parent.setLayout(m_Layout);
- m_Parent.addNotify();
-
- Dimension size = m_Layout.getDialogSize();
- Insets insets = m_Parent.insets();
-
- m_Parent.resize(insets.left + size.width + insets.right,
- insets.top + size.height + insets.bottom);
-
- // Control creation
- //----------------------------------------------------------------------
- IDOK = new Button ("OK");
- m_Parent.add(IDOK);
- m_Layout.setShape(IDOK, 129, 7, 50, 14);
-
- IDCANCEL = new Button ("Cancel");
- m_Parent.add(IDCANCEL);
- m_Layout.setShape(IDCANCEL, 129, 24, 50, 14);
-
- IDC_EDIT1 = new TextField ("");
- m_Parent.add(IDC_EDIT1);
- m_Layout.setShape(IDC_EDIT1, 58, 13, 62, 14);
-
- IDC_EDIT2 = new TextField ("");
- m_Parent.add(IDC_EDIT2);
- m_Layout.setShape(IDC_EDIT2, 58, 35, 62, 14);
-
- IDC_STATIC1 = new Label ("First Name:", Label.LEFT);
- m_Parent.add(IDC_STATIC1);
- m_Layout.setShape(IDC_STATIC1, 13, 13, 41, 8);
-
- IDC_STATIC2 = new Label ("Last Name:", Label.LEFT);
- m_Parent.add(IDC_STATIC2);
- m_Layout.setShape(IDC_STATIC2, 13, 37, 40, 8);
-
- IDC_CHECK1 = new Checkbox ("Married");
- m_Parent.add(IDC_CHECK1);
- m_Layout.setShape(IDC_CHECK1, 59, 55, 39, 10);
-
- m_fInitialized = true;
- return true;
- }
- }
-