home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 July / Chip_1998-07_cd.bin / zkuste / JBuilder / BDK / Win / bdk_sep97.exe / _SETUP.1 / PropertyDialog.java < prev    next >
Encoding:
Java Source  |  1997-09-10  |  1.3 KB  |  60 lines

  1.  
  2. // Support for PropertyEditor with custom editors.
  3.  
  4. package sun.beanbox;
  5.  
  6. import java.awt.*;
  7. import java.awt.event.*;
  8. import java.beans.*;
  9.  
  10. class PropertyDialog extends Dialog implements ActionListener {
  11.  
  12.     private Button doneButton;
  13.     private Component body;
  14.     private final static int vPad = 5;
  15.     private final static int hPad = 4;
  16.  
  17.     PropertyDialog(Frame frame, PropertyEditor pe, int x, int y) {
  18.     super(frame, pe.getClass().getName(), true);
  19.     new WindowCloser(this);
  20.     setLayout(null);
  21.  
  22.     body = pe.getCustomEditor();
  23.     add(body);
  24.  
  25.     doneButton = new Button("Done");
  26.     doneButton.addActionListener(this);
  27.     add(doneButton);
  28.  
  29.     setLocation(x, y);
  30.     show();
  31.     }
  32.  
  33.     public void actionPerformed(ActionEvent evt) {
  34.         // Button down.
  35.     dispose();
  36.     }
  37.  
  38.     public void doLayout() {
  39.         Insets ins = getInsets();
  40.     Dimension bodySize = body.getPreferredSize();
  41.     Dimension buttonSize = doneButton.getPreferredSize();
  42.  
  43.     int width = ins.left + 2*hPad + ins.right + bodySize.width;
  44.     int height = ins.top + 3*vPad + ins.bottom + bodySize.height +
  45.                             buttonSize.height;
  46.  
  47.         body.setBounds(ins.left+hPad, ins.top+vPad,
  48.                 bodySize.width, bodySize.height);
  49.  
  50.     doneButton.setBounds((width-buttonSize.width)/2,
  51.                 ins.top+(2*hPad) + bodySize.height,
  52.                 buttonSize.width, buttonSize.height);
  53.  
  54.     setSize(width, height);
  55.  
  56.     }
  57.  
  58. }
  59.  
  60.