home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / vpojava.DLL / SOURCE / PROGRESS_DIALOG < prev    next >
Text File  |  1998-03-18  |  2KB  |  89 lines

  1. import java.awt.*;
  2. import symantec.itools.awt.util.dialog.DialogBox;
  3. import symantec.itools.awt.util.ProgressBar;
  4.  
  5. public class ProgressDialog extends DialogBox
  6. {
  7.     public ProgressDialog(Frame parent, String title, String button, boolean modal)
  8.     {
  9.         super(parent, title, modal);
  10.  
  11.         // This code is automatically generated by Visual Cafe when you add
  12.         // components to the visual environment. It instantiates and initializes
  13.         // the components. To modify the code, only use code syntax that matches
  14.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  15.         // parse your Java file into its visual environment.
  16.         //{{INIT_CONTROLS
  17.         setLayout(new FlowLayout());
  18.         setSize(270, 73);
  19.         bar = new ProgressBar();
  20.         bar.setBounds(52, 25, 121, 23);
  21.         add(bar);
  22.         //}}
  23.  
  24.         if (button != null)
  25.         {
  26.             okButton = new Button(button);
  27.             okButton.setBounds(178, 22, 47, 29);
  28.             add(okButton);
  29.         }
  30.     }
  31.  
  32.     public ProgressDialog(Frame parent)
  33.     {
  34.         this(parent, true);
  35.     }
  36.  
  37.     public ProgressDialog(Frame parent, boolean modal)
  38.     {
  39.         this(parent, "Progress", modal);
  40.     }
  41.  
  42.     public ProgressDialog(Frame parent, String title, boolean modal)
  43.     {
  44.         this(parent, title, "Cancel", modal);
  45.     }
  46.  
  47.     public void setProgress(int amount)
  48.     {
  49.         if (bar != null)
  50.         {
  51.             try
  52.             {
  53.                  bar.setProgressPercent(amount);
  54.             }
  55.             catch (java.beans.PropertyVetoException pve)
  56.             {
  57.             }
  58.         }
  59.     }
  60.  
  61.     public void addNotify()
  62.     {
  63.         // Record the size of the window prior to calling parents addNotify.
  64.         Dimension d = getSize();
  65.         super.addNotify();
  66.  
  67.         if (fComponentsAdjusted)
  68.             return;
  69.  
  70.         // Adjust components according to the insets
  71.         setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
  72.         Component components[] = getComponents();
  73.         for (int i = 0; i < components.length; i++)
  74.         {
  75.             Point p = components[i].getLocation();
  76.             p.translate(insets().left, insets().top);
  77.             components[i].setLocation(p);
  78.         }
  79.         fComponentsAdjusted = true;
  80.     }
  81.  
  82.     // Used for addNotify check.
  83.     boolean fComponentsAdjusted = false;
  84.  
  85.     //{{DECLARE_CONTROLS
  86.     ProgressBar bar;
  87.     //}}
  88. }
  89.