home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SOURCE.BIN / ToolBarPanel.java < prev    next >
Encoding:
Java Source  |  1997-06-19  |  2.9 KB  |  102 lines

  1. package symantec.itools.awt.util;
  2.  
  3.  
  4. import java.awt.Color;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Dimension;
  8. import java.awt.FlowLayout;
  9. import java.awt.LayoutManager;
  10. import symantec.itools.awt.BorderPanel;
  11. import symantec.itools.awt.BevelStyle;
  12.  
  13. //    01/29/97    TWB    Integrated changes from Windows
  14.  
  15. /**
  16.  * ToolBarPanel component.
  17.  * This component creates a panel to which you can add buttons to create a toolbar
  18.  * in a window. Toolbars commonly contain buttons, but a ToolBarPanel can hold
  19.  * other types of components like static text, check boxes, even images.
  20.  *
  21.  * Tool bar components are separated with a ToolBarSpacer component.
  22.  *
  23.  * @see symantec.itools.awt.util.ToolBarSpacer
  24.  *
  25.  * @version 1.0, Nov 26, 1996
  26.  * @author Symantec
  27.  */
  28.  
  29.  
  30. public class ToolBarPanel
  31.     extends BorderPanel
  32. {
  33.     /**
  34.      * Create ToolBarPanel.  Default ToolBarPanel uses a BEVEL_RAISED style.
  35.      */
  36.  
  37.     public ToolBarPanel()
  38.     {
  39.         super.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
  40.         setBevelStyle(BevelStyle.BEVEL_RAISED);
  41.     }
  42.  
  43.     /**
  44.      * Takes no action.
  45.      * This is a standard Java AWT method which gets called to specify
  46.      * which layout manager should be used to layout the components in
  47.      * standard containers.
  48.      *
  49.      * Since layout managers CANNOT BE USED with this container the standard
  50.      * setLayout has been OVERRIDDEN for this container and does nothing.
  51.      *
  52.      * @param l the layout manager to use to layout this container's components
  53.      * (IGNORED)
  54.      * @see java.awt.Container#getLayout
  55.      **/
  56.     public void setLayout(LayoutManager lm)
  57.     {
  58.     }
  59.  
  60.     /**
  61.      * Returns the recommended dimensions to properly display this component.
  62.      * This is a standard Java AWT method which gets called to determine
  63.      * the recommended size of this component.
  64.      *
  65.      * @see #minimumSize
  66.      */
  67.     public synchronized Dimension preferredSize()
  68.     {
  69.         Dimension s = new Dimension(0, 20);
  70.         Component[] list = ((Container)super).getComponents();
  71.  
  72.         for (int i = 0; i < list.length; ++i) {
  73.             Dimension cs = list[i].size();
  74.             s.width += cs.width;
  75.             s.height = Math.max(s.height, cs.height);
  76.         }
  77.  
  78.         if (s.width == 0)
  79.             s.width = 50;
  80.  
  81.         s.width  += (padleft + padright + ixPad * 2);
  82.         s.height += (getLabelTopMargin() + padbottom + iyPadTop + iyPadBottom) + 1;
  83.  
  84.         return s;
  85.     }
  86.  
  87.     /**
  88.      * Returns the minimum dimensions to properly display this component.
  89.      * This is a standard Java AWT method which gets called to determine
  90.      * the minimum size of this component.
  91.      *
  92.      * In this case the minimum size is the same as the preferred size.
  93.      *
  94.      * @see #preferredSize
  95.      */
  96.     public synchronized Dimension minimumSize()
  97.     {
  98.         return preferredSize();
  99.     }
  100. }
  101.  
  102.