现在的位置: 首页 > 综合 > 正文

用java实现的Status Bar(zz)

2013年11月24日 ⁄ 综合 ⁄ 共 4133字 ⁄ 字号 评论关闭

/*===============================================================================

 * SlightBevelBorder.java

 *===============================================================================

 * auth:     Jason

 * CSDN ID:  Unagain

 * Email:    tl21cen@hotmail.com

 * date:    2006-4-11

 *===============================================================================

 */

package tl.util;

 

import java.awt.Color;

import java.awt.Component;

import java.awt.Graphics;

 

import javax.swing.border.SoftBevelBorder;

 

public class SlightBevelBorder extends SoftBevelBorder {

    private static final long serialVersionUID = 1L;

 

    public SlightBevelBorder(int bevelType) {

        super(bevelType);

    }

 

    public SlightBevelBorder(int bevelType, Color highlight, Color shadow) {

        super(bevelType, highlight, shadow);

    }

 

    /**

     * Paints the border for the specified component with the specified

     * position and size.

     * @param c the component for which this border is being painted

     * @param g the paint graphics

     * @param x the x position of the painted border

     * @param y the y position of the painted border

     * @param width the width of the painted border

     * @param height the height of the painted border

     */

    public void paintBorder(Component c, Graphics g, int x, int y, int width,

           int height) {

       Color oldColor = g.getColor();

        g.translate(x, y);

 

       if (bevelType == RAISED) {

           g.setColor(getHighlightOuterColor(c));

           g.drawLine(0, 0, width - 2, 0);

           g.drawLine(0, 1, 0, height - 2);

 

           g.setColor(getShadowOuterColor(c));

           g.drawLine(0, height - 1, width - 1, height - 1);

           g.drawLine(width - 1, 0, width - 1, height - 1);

          

       } else if (bevelType == LOWERED) {

           g.setColor(getShadowOuterColor(c));

           g.drawLine(0, 0, width - 2, 0);

           g.drawLine(0, 0, 0, height - 2);

          

           g.setColor(getHighlightOuterColor(c));

           g.drawLine(0, height - 1, width - 1, height - 1);

           g.drawLine(width - 1, 0, width - 1, height);

       }

        g.translate(-x, -y);

        g.setColor(oldColor);

    }

}

/*===============================================================================

 * StatusbarBuilder.java

 *===============================================================================

 *  This program is free software; you can redistribute it and/or modify

 *  it under the terms of the GNU General Public License as published by

 *  the Free Software Foundation; either version 2 of the License, or

 *  (at your option) any later version.

 * 

 *  This program is distributed in the hope that it will be useful,

 *  but WITHOUT ANY WARRANTY; without even the implied warranty of

 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

 *  GNU General Public License for more details.

 * 

 *  You should have received a copy of the GNU General Public License

 *  along with this program; if not, write to the Free Software

 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

 *===============================================================================

 * auth:    Jason

 * CSDN ID:    Unagain

 * Email:    tl21cen@hotmail.com

 * date:    2006-4-11

 *===============================================================================

 */

package tl.util;

 

import java.awt.BorderLayout;

import java.awt.Color;

import java.awt.Component;

import java.awt.Cursor;

import java.awt.Dimension;

import java.awt.Graphics;

import java.awt.Point;

import java.awt.Rectangle;

import java.awt.Window;

import java.awt.event.MouseEvent;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.util.Hashtable;

 

import javax.swing.Box;

import javax.swing.BoxLayout;

import javax.swing.JComponent;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.border.AbstractBorder;

import javax.swing.border.BevelBorder;

import javax.swing.border.EmptyBorder;

import javax.swing.event.MouseInputAdapter;

import javax.swing.text.JTextComponent;

 

//class StatusBar extends JComponent {

public class StatusbarBuilder {

    //final static Dimension XGAP = new Dimension(2, 0);

 

    private JPanel bar;

 

    /**

     * matains all instances created, each instance associate

     * with an existing window object.<br>

     * you can create and to obtain a instance using newInstance

     * method with a specified window object.

     */

    private static

    Hashtable<Window, StatusbarBuilder> instances =

       new Hashtable<Window, StatusbarBuilder>();

 

    private Window window;

 

    final public static int

抱歉!评论已关闭.