?? bordershop.java
字號:
/* * @(#) 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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -