⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basicborders.java

📁 gcc的JAVA模块的源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   * feels better use different borders for their progress bars, or   * they will look really terrible.   *   * <p><img src="doc-files/BasicBorders-1.png" width="120" height="80"   * alt="[A screen shot of a border returned by this method]" />   */  public static Border getProgressBarBorder()  {    /* There does not seem to exist a way to parametrize the color     * or thickness of the border through UIDefaults.     */    return new BorderUIResource.LineBorderUIResource(Color.green, 2);  }  /**   * Returns a border that is composed of a raised bevel border and a   * one-pixel thick line border.   *   * <p><img src="doc-files/BasicBorders-2.png" width="300" height="200"   * alt="[A screen shot of a border returned by this method]" />   *   * <p>The colors of the border are retrieved from the   * <code>UIDefaults</code> of the currently active look and feel   * using the keys <code>&#x201c;InternalFrame.borderShadow&#x201d;</code>,   * <code>&#x201c;InternalFrame.borderDarkShadow&#x201d;</code>,   * <code>&#x201c;InternalFrame.borderLight&#x201d;</code>,   * <code>&#x201c;InternalFrame.borderHighlight&#x201d;</code>, and   * (for the inner one-pixel thick line)   * <code>&#x201c;InternalFrame.borderColor&#x201d;</code>.   */  public static Border getInternalFrameBorder()  {    UIDefaults defaults;    Color shadow, darkShadow, highlight, lightHighlight, line;    /* See comment in methods above for why this border is not shared. */    defaults = UIManager.getLookAndFeelDefaults();        shadow = defaults.getColor("InternalFrame.borderShadow");    darkShadow = defaults.getColor("InternalFrame.borderDarkShadow");    highlight = defaults.getColor("InternalFrame.borderLight");    lightHighlight = defaults.getColor("InternalFrame.borderHighlight");    line = defaults.getColor("InternalFrame.borderColor");    return new BorderUIResource.CompoundBorderUIResource(      /* outer border */      new BorderUIResource.BevelBorderUIResource(        BevelBorder.RAISED,        (highlight != null) ? highlight : Color.lightGray,        (lightHighlight != null) ? lightHighlight : Color.white,        (darkShadow != null) ? darkShadow : Color.black,        (shadow != null) ? shadow : Color.gray),      /* inner border */      new BorderUIResource.LineBorderUIResource(        (line != null) ? line : Color.lightGray));  }  /**   * Returns a shared MarginBorder.   */  static Border getMarginBorder()  // intentionally not public  {    /* Swing is not designed to be thread-safe, so there is no     * need to synchronize the access to the global variable.     */    if (sharedMarginBorder == null)      sharedMarginBorder = new MarginBorder();    return sharedMarginBorder;  }      /**   * A border whose appearance depends on the state of   * the enclosed button.   *   * <p><img src="doc-files/BasicBorders.ButtonBorder-1.png" width="300"   * height="170" alt="[A screen shot of this border]" />   *   * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel   *   * @author Sascha Brawer (brawer@dandelis.ch)   */  public static class ButtonBorder    extends AbstractBorder    implements Serializable, UIResource  {    /**     * Determined using the <code>serialver</code> tool     * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.     */    static final long serialVersionUID = -157053874580739687L;            /**     * The color for drawing the shaded parts of the border.     * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel     */    protected Color shadow;            /**     * The color for drawing the dark shaded parts of the border.     * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel     */    protected Color darkShadow;            /**     * The color for drawing the highlighted parts of the border.     * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel     */    protected Color highlight;            /**     * The color for drawing the bright highlighted parts of the border.     * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel     */    protected Color lightHighlight;            /**     * Constructs a new border for drawing a button in the Basic     * look and feel.     *     * @param shadow the shadow color.     * @param darkShadow a darker variant of the shadow color.     * @param highlight the highlight color.     * @param lightHighlight a brighter variant of the highlight  color.     */    public ButtonBorder(Color shadow, Color darkShadow,                        Color highlight, Color lightHighlight)    {      /* These colors usually come from the UIDefaults of the current       * look and feel. Use fallback values if the colors are not       * supplied.  The API specification is silent about what       * behavior is expected for null colors, so users should not       * rely on this fallback (which is why it is not documented in       * the above Javadoc).       */      this.shadow = (shadow != null) ? shadow : Color.gray;      this.darkShadow = (darkShadow != null) ? darkShadow : Color.black;      this.highlight = (highlight != null) ? highlight : Color.lightGray;      this.lightHighlight = (lightHighlight != null)        ? lightHighlight        : Color.white;    }        /**     * Paints the ButtonBorder around a given component.     *     * @param c the component whose border is to be painted.     * @param g the graphics for painting.     * @param x the horizontal position for painting the border.     * @param y the vertical position for painting the border.     * @param width the width of the available area for painting the border.     * @param height the height of the available area for painting the border.     *     * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel     */    public void paintBorder(Component c, Graphics  g,                            int x, int y, int width, int height)    {      ButtonModel bmodel = null;            if (c instanceof AbstractButton)        bmodel = ((AbstractButton) c).getModel();            BasicGraphicsUtils.drawBezel(        g, x, y, width, height,        /* pressed */ (bmodel != null)                        && /* mouse button pressed */ bmodel.isPressed()                        && /* mouse inside */ bmodel.isArmed(),        /* default */ (c instanceof JButton)                        && ((JButton) c).isDefaultButton(),        shadow, darkShadow, highlight, lightHighlight);    }            /**     * Measures the width of this border.     *     * <p>Although the thickness of the actually painted border     * depends on the state of the enclosed component, this     * measurement always returns the same amount of pixels.  Indeed,     * it would be rather confusing if a button was appearing to     * change its size depending on whether it is pressed or not.     *     * @param c the component whose border is to be measured.     *     * @return an Insets object whose <code>left</code>,     *         <code>right</code>, <code>top</code> and     *         <code>bottom</code> fields indicate the width of the     *         border at the respective edge.     *     * @see #getBorderInsets(java.awt.Component, java.awt.Insets)      */    public Insets getBorderInsets(Component c)    {      /* There is no obvious reason for overriding this method, but we       * try to have exactly the same API as the Sun reference       * implementation.       */      return getBorderInsets(c, null);    }        /**     * Measures the width of this border, storing the results into a     * pre-existing Insets object.     *     * <p>Although the thickness of the actually painted border     * depends on the state of the enclosed component, this     * measurement always returns the same amount of pixels.  Indeed,     * it would be rather confusing if a button was appearing to     * change its size depending on whether it is pressed or not.     *     * @param insets an Insets object for holding the result values.     *        After invoking this method, the <code>left</code>,     *        <code>right</code>, <code>top</code> and     *        <code>bottom</code> fields indicate the width of the     *        border at the respective edge.     *     * @return the same object that was passed for <code>insets</code>.     *     * @see #getBorderInsets()     */    public Insets getBorderInsets(Component c, Insets insets)    {      /* The exact amount has been determined using a test program       * that was run on the Sun reference implementation. With       * Apple/Sun JDK 1.3.1 on MacOS X 10.1.5, the result is       * [3, 3, 3, 3]. With Sun JDK 1.4.1_01 on Linux/x86, the       * result is [2, 3, 3, 3]. We use the values from the 1.4.1_01       * release.       */      if (insets == null)        return new Insets(2, 3, 3, 3);      insets.top = 2;      insets.bottom = insets.left = insets.right = 3;      return insets;    }  }      /**   * A border that makes its enclosed component appear as lowered   * into the surface. Typically used for text fields.   *   * <p><img src="doc-files/BasicBorders.FieldBorder-1.png" width="500"   * height="200" alt="[A screen shot of this border]" />   *   * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawEtchedRect   *   * @author Sascha Brawer (brawer@dandelis.ch)   */  public static class FieldBorder    extends AbstractBorder    implements UIResource  {    /**     * Determined using the <code>serialver</code> tool     * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.     */    static final long serialVersionUID = 949220756998454908L;    /**     * The color for drawing the outer half of the top and left     * edges.     */    protected Color shadow;    /**     * The color for drawing the inner half of the top and left     * edges.     */    protected Color darkShadow;    /**     * The color for drawing the inner half of the bottom and right     * edges.     */    protected Color highlight;    /**     * The color for drawing the outer half of the bottom and right     * edges.     */    protected Color lightHighlight;    /**     * Constructs a new border for drawing a text field in the Basic     * look and feel.     *     * @param shadow the color for drawing the outer half     *        of the top and left edges.     *     * @param darkShadow the color for drawing the inner half     *        of the top and left edges.     *     * @param highlight the color for drawing the inner half     *        of the bottom and right edges.     *     * @param lightHighlight the color for drawing the outer half     *        of the bottom and right edges.     */    public FieldBorder(Color shadow, Color darkShadow,                       Color highlight, Color lightHighlight)    {      /* These colors usually come from the UIDefaults of the current       * look and feel. Use fallback values if the colors are not       * supplied.  The API specification is silent about what       * behavior is expected for null colors, so users should not       * rely on this fallback (which is why it is not documented in       * the above Javadoc).       */      this.shadow = (shadow != null) ? shadow : Color.gray;      this.darkShadow = (darkShadow != null) ? darkShadow : Color.black;      this.highlight = (highlight != null) ? highlight : Color.lightGray;      this.lightHighlight = (lightHighlight != null)        ? lightHighlight : Color.white;    }        /**     * Paints the FieldBorder around a given component.     *     * @param c the component whose border is to be painted.     * @param g the graphics for painting.     * @param x the horizontal position for painting the border.     * @param y the vertical position for painting the border.     * @param width the width of the available area for painting the border.     * @param height the height of the available area for painting the border.     *     * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawEtchedRect     */    public void paintBorder(Component c, Graphics  g,                            int x, int y, int width, int height)    {      BasicGraphicsUtils.drawEtchedRect(g, x, y, width, height,                                        shadow, darkShadow,                                        highlight, lightHighlight);    }            /**     * Measures the width of this border.     *     * @param c the component whose border is to be measured.     *        If <code>c</code> is an instance of {@link     *        javax.swing.text.JTextComponent}, its margin is     *        added to the border size.     *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -