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

  1.  
  2. /**
  3.  * Take a generic component Editor and wrap it in a Dialog box.
  4.  * this includes adding the Frame and the "ok" and "cancel" buttons.
  5.  */
  6.  
  7. package sun.beanbox;
  8.  
  9. import java.awt.*;
  10. import java.awt.event.*;
  11. import java.beans.*;
  12.  
  13.  
  14. public class CustomizerDialog extends Dialog implements ActionListener {
  15.  
  16.     private Component body;
  17.     private Button doneButton;
  18.     private static int vPad = 5;
  19.     private static int hPad = 4;
  20.  
  21.     public CustomizerDialog(Frame frame, Customizer customizer, Object target) {
  22.     super(frame, customizer.getClass().getName(), true);
  23.     new WindowCloser(this);
  24.         setLayout(null);
  25.  
  26.         body = (Component)customizer;
  27.     add(body);
  28.  
  29.     doneButton = new Button("Done");
  30.     doneButton.addActionListener(this);
  31.     add(doneButton);
  32.  
  33.         int x = frame.getLocation().x + 30;
  34.         int y = frame.getLocation().y + 100;
  35.     setLocation(x,y);
  36.  
  37.     show();
  38.     }
  39.  
  40.     public void doLayout() {
  41.         Insets ins = getInsets();
  42.     Dimension bodySize = body.getPreferredSize();
  43.     Dimension buttonSize = doneButton.getPreferredSize();
  44.  
  45.     int width = ins.left + 2*hPad + ins.right + bodySize.width;
  46.     int height = ins.top + 3*vPad + ins.bottom + bodySize.height +
  47.                             buttonSize.height;
  48.  
  49.         body.setBounds(ins.left+hPad, ins.top+vPad,
  50.                 bodySize.width, bodySize.height);
  51.  
  52.     doneButton.setBounds((width-buttonSize.width)/2,
  53.                 ins.top+(2*hPad) + bodySize.height,
  54.                 buttonSize.width, buttonSize.height);
  55.  
  56.     setSize(width, height);
  57.     }
  58.  
  59.     public void actionPerformed(ActionEvent evt) {
  60.     // Our "done" button got pushed.
  61.     dispose();
  62.     }
  63.  
  64. }
  65.