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

📄 dragpanel.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
字号:
/* * DragPanel.java * * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis * * 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 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * */package org.executequery.base;import java.awt.BasicStroke;import java.awt.Color;import java.awt.Component;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Insets;import java.awt.Rectangle;import javax.swing.JPanel;import javax.swing.border.Border;/* ---------------------------------------------------------- * CVS NOTE: Changes to the CVS repository prior to the  *           release of version 3.0.0beta1 has meant a  *           resetting of CVS revision numbers. * ---------------------------------------------------------- *//** * * @author   Takis Diakoumis * @version  $Revision: 1.3 $ * @date     $Date: 2006/05/14 06:56:55 $ */public class DragPanel extends JPanel {        private int tabX;    private int tabWidth;    private int tabHeight;    /** the tab rectangle portion */    private Rectangle tabRect;        /** the drag panel border */    private Border border;        /** the border insets */    private static Insets borderInsets;        public DragPanel(Rectangle bounds) {        this(null, bounds);    }    public DragPanel(Rectangle tabBounds, Rectangle bounds) {                if (borderInsets == null) {            borderInsets = new Insets(0,0,0,0);        }        init(tabBounds, bounds);        setBorder(new PanelBorder());    }    protected Rectangle getTabRectangle() {        return tabRect;    }        private void init(Rectangle tabBounds, Rectangle bounds) {        if (tabBounds != null) {            tabX = tabBounds.x;            tabWidth = tabBounds.width;            tabHeight = tabBounds.height;        }        tabRect = tabBounds;        setBounds(bounds);    }    public void reset(Rectangle bounds) {        reset(null, bounds);    }    public void reset(Rectangle tabBounds, Rectangle bounds) {        init(tabBounds, bounds);        repaint();    }        public boolean isOpaque() {        return false;    }        class PanelBorder implements Border {                /** the paint stroke */        private BasicStroke stroke = new BasicStroke(2.0f);                public void paintBorder(Component c,                        Graphics g,                        int x,                        int y,                        int width,                        int height) {            Graphics2D g2d = (Graphics2D)g;                        g2d.setStroke(stroke);            g2d.setColor(Color.RED.brighter().brighter());                        if (tabRect == null) {                g2d.drawRect(x + 1, y + 1, width - 2, height - 2);                return;            }                        // -------------------------            // tab border             // tab top line            g2d.drawLine(tabX + x + 1, y + 1,                          tabX + x + tabWidth - 2, y + 1);            // tab left            g2d.drawLine(tabX + x + 1, y,                          tabX + x + 1, y + tabHeight);            // tab right            g.drawLine(tabX + x + tabWidth - 2, y,                        tabX + x + tabWidth - 2, y + tabHeight);            // ---------------------------            // remaining border                        // top left side            g2d.drawLine(x, y + tabHeight,                        x + tabX, y + tabHeight);            // top right side            g2d.drawLine(x + tabX + tabWidth, y + tabHeight,                       x + width, y + tabHeight);            // left side            g2d.drawLine(x + 1, y + tabHeight, x + 1, y + height);            // right side            g2d.drawLine(x + width - 1, y + tabHeight, x + width - 1, y + height - 1);            // bottom            g2d.drawLine(x, y + height - 1, x + width - 1, y + height - 1);        }              public Insets getBorderInsets(Component c) {            return borderInsets;        }                public boolean isBorderOpaque() {            return true;        }            }    }

⌨️ 快捷键说明

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