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

📄 toolbar.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        int ey = e.getY();        int x = getX();        int y = getY();        int w = getParent().getWidth();        int h = getParent().getHeight();                int locX = -1;        int locY = -1;                if (resizing) {                        if (getWidth() - ex - m_XDifference >= resizeRegionX) {                locX = getX() + ex - m_XDifference;                setBounds(locX, getY(), getWidth() - ex - m_XDifference, getHeight());            }                        else {                                if (ex + resizeRegionX < rightX) {                    locX = rightX - resizeRegionX;                    setBounds(locX, getY(), resizeRegionX, getHeight());                }                else {                    locX = ex;                    setBounds(locX, getY(), resizeRegionX, getHeight());                }                            }                        validate();            firePropertyChange(TOOL_BAR_RESIZING, x, locX);        }                else if (dragging) {                        if ((ey + y > 0 && ey + y < h) && (ex + x > 0 && ex + x < w)) {                locX = ex - m_XDifference + x;                locY = ey - m_YDifference + y;            }                        else if (!(ey + y > 0 && ey + y < h) && (ex + x > 0 && ex + x < w)) {                                if (!(ey + y > 0) && ey + y < h) {                    locX = ex - m_XDifference + x;                    locY = 0 - m_YDifference;                }                else if (ey + y > 0 && !(ey + y < h)) {                    locX = ex - m_XDifference + x;                    locY = h - m_YDifference;                }                            }                        else if ((ey + y > 0 && ey + y < h) && !(ex + x > 0 && ex + x < w)) {                                if (!(ex + x > 0) && ex + x < w) {                    locX = 0 - m_XDifference;                    locY = ey - m_YDifference + y;                }                else if (ex + x > 0 && !(ex + x < w)) {                    locX = w - m_XDifference;                    locY = ey - m_YDifference + y;                }                            }                        else if (!(ey + y > 0) && ey + y < h && !(ex + x > 0) && ex + x < w) {                locX = 0 - m_XDifference;                locY = 0 - m_YDifference;            }                        else if (!(ey + y > 0) && ey + y < h && ex + x > 0 && !(ex + x < w)) {                locX = w - m_XDifference;                locY = 0 - m_YDifference;            }                        else if (ey + y > 0 && !(ey + y < h) && !(ex + x > 0) && ex + x < w) {                locX = 0 - m_XDifference;                locY = h - m_YDifference;            }                        else if (ey + y > 0 && !(ey + y < h) && ex + x > 0 && !(ex + x < w)) {                locX = w - m_XDifference;                locY = h - m_YDifference;            }                        if (locX < 0) {                locX = 0;            }                        int parentHeight = parent.getHeight();            //int maxY = parentHeight - (ToolBarLayout.getRowHeight() / 2);            int maxY = parentHeight - (getHeight() / 2);            if (locY < 0) {                locY = 0;            }            else if (locY > maxY) {                firePropertyChange(TOOL_BAR_MOVING, m_YDifference, locY);                parentHeight = parent.getHeight();                                if (locY > parentHeight) {                    locY = parentHeight;                }                            }                        setLocation(locX, locY);                    }            }        public void mousePressed(MouseEvent e) {        int xPos = getX();        rightX = xPos + getWidth();        m_XDifference = e.getX();        m_YDifference = e.getY();                if (m_XDifference <= resizeRegionX && xPos != 0) {            resizing = true;        }        else {            firePropertyChange(TOOL_BAR_BEGIN_MOVING, 0, 1);            dragging = true;        }            }        public void mouseReleased(MouseEvent e) {                if (dragging) {            firePropertyChange(TOOL_BAR_MOVED, 0, 1);        }        firePropertyChange(TOOL_BAR_DESELECTED, 0, 1);        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));        dragging = false;        resizing = false;    }        public void mouseExited(MouseEvent e) {        if (!resizing) {            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));        }    }        public void mouseMoved(MouseEvent e) {        if (e.getX() > resizeRegionX && !resizing) {            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));        }    }        public void mouseEntered(MouseEvent e) {        if (!dragging && !resizing && e.getX() <= resizeRegionX && getX() != 0) {            setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));        }    }        public void mouseClicked(MouseEvent e) {}        public String toString() {        return "Tool Bar: " + name;    }    private static Border widgetBorder;    private static Color middleground;    private static Color background;    private static Color foreground;    /** <p>Small widget placed on the left edge of the tool bar. */    class ToolBarSelectionWidget extends JPanel {        /** fixed width - 9px */        protected static final int WIDTH = 9;        /** indicates whether the Java L&F (or a derivative) is used */        private boolean isJavaLookAndFeel;        public ToolBarSelectionWidget() {            isJavaLookAndFeel = GUIUtils.isMetalLookAndFeel();            if (background == null) {                background = UIManager.getDefaults().getColor(                                            "InternalFrame.borderDarkShadow");            }            if (foreground == null) {                foreground = Color.WHITE;            }            //int width = 9;            //int height = 29;            //setPreferredSize(new Dimension(width, height));        }        public int getWidth() {            return WIDTH;        }                public boolean isOpaque() {            return false;        }                public void paintComponent(Graphics g) {            int height = getHeight();            if (!isJavaLookAndFeel) {                                if (middleground == null) {                    middleground = UIManager.getDefaults().getColor("control");                }                                int start = (height - 13) / 2;                for (int i = 0; i < 3; i++) {                    g.setColor(background);                    g.drawLine(2, start, 3, start);                    g.drawLine(2, start, 2, start + 2);                    g.setColor(middleground);                    g.drawLine(4, start, 4, start);                    g.drawLine(3, start + 1, 3, start + 1);                    g.drawLine(2, start + 2, 2, start + 2);                    g.setColor(foreground);                    g.drawLine(3, start + 2, 4, start + 2);                    g.drawLine(4, start + 1, 4, start + 1);                    start += 6;                }                            }            else {                Shape clip = g.getClip();                g.setClip(1, 1, getWidth() - 2, height - 4);                g.setColor(foreground);                for (int x = 1; x <= height; x += 4) {                    for (int y = 1; y <= height; y += 4) {                        g.drawLine(x, y, x, y);                        g.drawLine(x + 2, y + 2, x + 2, y + 2);                    }                }                g.setColor(background);                for (int x = 1; x <= height; x += 4) {                    for (int y = 1; y <= height; y += 4) {                        g.drawLine(x + 1, y + 1, x + 1, y + 1);                        g.drawLine(x + 3, y + 3, x + 3, y + 3);                    }                }                g.setClip(clip);            }        }    } // ToolBarSelectionWidget}

⌨️ 快捷键说明

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