bordershop.java

来自「该系统是一个基于p2p的即时聊天系统」· Java 代码 · 共 169 行

JAVA
169
字号
/* * @(#) BorderShop.java * Copyright 2004 HWStudio. All rights reserved. */package hws.item.smart.misc;//导入核心Java类库import java.awt.Color;import java.awt.Component;import java.awt.Graphics;import javax.swing.BorderFactory;import javax.swing.border.Border;import javax.swing.border.BevelBorder;/** * 定义所有边框的静态常量 * * @version 0.1 2005-08-16 * @author Hwerz */public class BorderShop extends Object {    /*------------------------------------------------------------------------*     *                                属性定义                                *     *------------------------------------------------------------------------*/    /**     * 下凹边框     */    public static final Border LOWERED_THIN_BEVEL_BORDER =        new ThinBevelBorder(ThinBevelBorder.LOWERED);    /**     * 标题边框     */    public static final Border BASIC_INFO_BORDER = BorderFactory        .createTitledBorder(BorderFactory.createEtchedBorder(), "基本信息");    /**     * 标题边框     */    public static final Border OPTIONAL_INFO_BORDER = BorderFactory        .createTitledBorder(BorderFactory.createEtchedBorder(), "可选信息");    /**     * 标题边框     */    public static final Border PERSONAL_INFO_BORDER = BorderFactory        .createTitledBorder(BorderFactory.createEtchedBorder(), "个人信息");    /**     * 标题边框     */    public static final Border SMTP_INFO_BORDER = BorderFactory        .createTitledBorder(BorderFactory.createEtchedBorder(), "发送邮件服务器");    /**     * 标题边框     */    public static final Border POP3_INFO_BORDER = BorderFactory        .createTitledBorder(BorderFactory.createEtchedBorder(), "接收邮件服务器");    /**     * 标题边框     */    public static final Border LOGON_INFO_BORDER = BorderFactory        .createTitledBorder(BorderFactory.createEtchedBorder(), "登录信息");    /**     * 标题边框     */    public static final Border EN_SAMPLE_BORDER = BorderFactory        .createTitledBorder(BorderFactory.createEtchedBorder(), "英文示例");    /**     * 标题边框     */    public static final Border CN_SAMPLE_BORDER = BorderFactory        .createTitledBorder(BorderFactory.createEtchedBorder(), "中文示例");    /*------------------------------------------------------------------------*     *                                 内部类                                 *     *------------------------------------------------------------------------*/    /**     * 下凹边框     */    static class ThinBevelBorder extends BevelBorder {        /**         * Create a new instance of this class         *         * @param bevelType the type of bevel for the border         */        public ThinBevelBorder(int bevelType) {            super(bevelType);        }        /**         * Create a new instance of this class         *         * @param bevelType the type of bevel for the border         * @param highlight the color to use for the bevel highlight         * @param shadow the color to use for the bevel shadow         */        public ThinBevelBorder(int bevelType, Color highlight, Color shadow) {            super(bevelType, highlight, shadow);        }        /**         * Create a new instance of this class         *         * @param bevelType the type of bevel for the border         * @param highlightOuterColor the color to use for the bevel outer         * highlight         * @param highlightInnerColor the color to use for the bevel inner         * highlight         * @param shadowOuterColor the color to use for the bevel outer shadow         * @param shadowInnerColor the color to use for the bevel inner shadow         */        public ThinBevelBorder(int bevelType, Color highlightOuterColor,            Color highlightInnerColor, Color shadowOuterColor,            Color shadowInnerColor) {            super(bevelType, highlightOuterColor, highlightInnerColor,                shadowOuterColor, shadowInnerColor);        }        /**         * 覆盖超类BevelBorder的方法:绘制凸起时的边框         *         * @param c 添加该边框的组件         * @param g Graphics对象         * @param x X坐标         * @param y Y坐标         * @param width 宽度         * @param height 高度         */        protected void paintRaisedBevel(Component c, Graphics g, int x, int y,            int width, int height) {            try {                Color oldColor = g.getColor();                 int h = height;                int w = width;                g.translate(x, y);                g.setColor(getHighlightInnerColor(c));                g.drawLine(0, 0, 0, h - 1);                g.drawLine(1, 0, w - 1, 0);                g.setColor(getShadowInnerColor(c));                g.drawLine(1, h - 1, w - 1, h - 1);                g.drawLine(w - 1, 1, w - 1, h - 2);                g.translate(-x, -y);                g.setColor(oldColor);            } catch (NullPointerException e) {                e.printStackTrace();            }        }        /**         * 覆盖超类BevelBorder的方法:绘制凹下时的边框         *         * @param c 添加该边框的组件         * @param g Graphics对象         * @param x X坐标         * @param y Y坐标         * @param width 宽度         * @param height 高度         */        protected void paintLoweredBevel(Component c, Graphics g, int x, int y,            int width, int height) {            try {                Color oldColor = g.getColor();                int h = height;                int w = width;                g.translate(x, y);                g.setColor(getShadowInnerColor(c));                g.drawLine(0, 0, 0, h - 1);                g.drawLine(1, 0, w - 1, 0);                g.setColor(getHighlightOuterColor(c));                g.drawLine(1, h - 1, w - 1, h - 1);                g.drawLine(w - 1, 1, w - 1, h - 2);                g.translate(-x, -y);                g.setColor(oldColor);            } catch (NullPointerException e) {                e.printStackTrace();            }        }    }}

⌨️ 快捷键说明

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