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

📄 flattabbedpaneui.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            default:                rlen = tabRect.height;                start = tabRect.y;                end = tabRect.y + tabRect.height + 1;                ostart = tabRect.x;        }                int rcnt = rlen/CROP_SEGMENT;                if (rlen%CROP_SEGMENT > 0) {            rcnt++;        }                int npts = 2 + (rcnt*8);        int xp[] = new int[npts];        int yp[] = new int[npts];        int pcnt = 0;                xp[pcnt] = ostart;        yp[pcnt++] = end;        xp[pcnt] = ostart;        yp[pcnt++] = start;        for(int i = 0; i < rcnt; i++) {            for(int j = 0; j < xCropLen.length; j++) {                xp[pcnt] = cropline - xCropLen[j];                yp[pcnt] = start + (i*CROP_SEGMENT) + yCropLen[j];                if (yp[pcnt] >= end) {                    yp[pcnt] = end;                    pcnt++;                    break;                }                pcnt++;            }        }        if (tabPlacement == JTabbedPane.TOP || tabPlacement == JTabbedPane.BOTTOM) {            return new Polygon(xp, yp, pcnt);                    } else { // LEFT or RIGHT            return new Polygon(yp, xp, pcnt);        }    }        /* If tabLayoutPolicy == SCROLL_TAB_LAYOUT, this method will paint an edge     * indicating the tab is cropped in the viewport display     */    private void paintCroppedTabEdge(Graphics g, int tabPlacement, int tabIndex,            boolean isSelected, int x, int y) {                switch(tabPlacement) {                        case LEFT:            case RIGHT:                int xx = x;                g.setColor(shadow);                                while(xx <= x+rects[tabIndex].width) {                                        for (int i=0; i < xCropLen.length; i+=2) {                        g.drawLine(xx+yCropLen[i], y-xCropLen[i],                                xx+yCropLen[i+1]-1, y-xCropLen[i+1]);                    }                                        xx+=CROP_SEGMENT;                                    }                                break;                            case TOP:            case BOTTOM:            default:                int yy = y;                g.setColor(controlShadow);                                while(yy <= y+rects[tabIndex].height) {                                        for (int i=0; i < xCropLen.length; i+=2) {                        g.drawLine(x-xCropLen[i], yy+yCropLen[i],                                x-xCropLen[i+1], yy+yCropLen[i+1]-1);                    }                                        yy+=CROP_SEGMENT;                                    }                        }            }        protected void layoutLabel(int tabPlacement,            FontMetrics metrics, int tabIndex,            String title, Icon icon,            Rectangle tabRect, Rectangle iconRect,            Rectangle textRect, boolean isSelected ) {                textRect.x = textRect.y = iconRect.x = iconRect.y = 0;                View v = getTextViewForTab(tabIndex);                if (v != null) {            tabPane.putClientProperty("html", v);        }                SwingUtilities.layoutCompoundLabel((JComponent) tabPane,                metrics, title, icon,                SwingUtilities.CENTER,                SwingUtilities.CENTER,                SwingUtilities.CENTER,                SwingUtilities.TRAILING,                tabRect,                iconRect,                textRect,                textIconGap);                tabPane.putClientProperty("html", null);                int xNudge = getTabLabelShiftX(tabPlacement, tabIndex, isSelected);        int yNudge = getTabLabelShiftY(tabPlacement, tabIndex, isSelected);        iconRect.x += xNudge;        iconRect.y += yNudge;        textRect.x += xNudge;        textRect.y += yNudge;            }        protected void paintIcon(Graphics g, int tabPlacement,            int tabIndex, Icon icon, Rectangle iconRect,            boolean isSelected ) {        if (icon != null) {                        int y = iconRect.y - 1;                        if (!isSelected)                y += 2;                        icon.paintIcon(tabPane, g, iconRect.x, y);                    }            }        protected void paintText(Graphics g, int tabPlacement,            Font font, FontMetrics metrics, int tabIndex,            String title, Rectangle textRect,            boolean isSelected) {                g.setFont(font);                View v = getTextViewForTab(tabIndex);                if (v != null) {            v.paint(g, textRect); // html        }                else {  // plain text            int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);                        if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {                g.setColor(tabPane.getForegroundAt(tabIndex));                int y = textRect.y + metrics.getAscent()-1;                                if (!isSelected)                    y+=2;                                BasicGraphicsUtils.drawStringUnderlineCharAt(g,                        title, mnemIndex,                        textRect.x, y);                            }                        else { // tab disabled                g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());                BasicGraphicsUtils.drawStringUnderlineCharAt(g,                        title, mnemIndex,                        textRect.x, textRect.y + metrics.getAscent() - 1);                g.setColor(tabPane.getBackgroundAt(tabIndex).darker());                BasicGraphicsUtils.drawStringUnderlineCharAt(g, title, mnemIndex,                        textRect.x - 1,                        textRect.y + metrics.getAscent() - 1);            }                    }            }            protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected) {        Rectangle tabRect = rects[tabIndex];        int nudge = 0;        switch(tabPlacement) {            case LEFT:                nudge = isSelected? -1 : 1;                break;            case RIGHT:                nudge = isSelected? 1 : -1;                break;            case BOTTOM:            case TOP:            default:                nudge = tabRect.width % 2;        }        return nudge;    }        protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected) {        Rectangle tabRect = rects[tabIndex];        int nudge = 0;        switch(tabPlacement) {            case BOTTOM:                nudge = isSelected? 1 : -1;                break;            case LEFT:            case RIGHT:                nudge = tabRect.height % 2;                break;            case TOP:            default:                nudge = isSelected? -1 : 1;;        }        return nudge;    }        protected void paintFocusIndicator(Graphics g, int tabPlacement,            Rectangle[] rects, int tabIndex,            Rectangle iconRect, Rectangle textRect,            boolean isSelected) {                Rectangle tabRect = rects[tabIndex];        if (tabPane.hasFocus() && isSelected) {            int x, y, w, h;            g.setColor(focus);            switch(tabPlacement) {                case LEFT:                    x = tabRect.x + 3;                    y = tabRect.y + 3;                    w = tabRect.width - 5;                    h = tabRect.height - 6;                    break;                case RIGHT:                    x = tabRect.x + 2;                    y = tabRect.y + 3;                    w = tabRect.width - 5;                    h = tabRect.height - 6;                    break;                case BOTTOM:                    x = tabRect.x + 3;                    y = tabRect.y + 2;                    w = tabRect.width - 6;                    h = tabRect.height - 5;                    break;                case TOP:                default:                    x = tabRect.x + 3;                    y = tabRect.y + 3;                    w = tabRect.width - 6;                    h = tabRect.height - 5;            }            BasicGraphicsUtils.drawDashedRect(g, x, y, w, h);        }    }        /**     * this function draws the border around each tab     * note that this function does now draw the background of the tab.     * that is done elsewhere     */    protected void paintTabBorder(Graphics g, int tabPlacement,            int tabIndex,            int x, int y, int w, int h,            boolean isSelected ) {        g.setColor(lightHighlight);                switch (tabPlacement) {            case LEFT:                g.drawLine(x+1, y+h-2, x+1, y+h-2); // bottom-left highlight                g.drawLine(x, y+2, x, y+h-3); // left highlight                g.drawLine(x+1, y+1, x+1, y+1); // top-left highlight                g.drawLine(x+2, y, x+w-1, y); // top highlight                                g.setColor(shadow);                g.drawLine(x+2, y+h-2, x+w-1, y+h-2); // bottom shadow                                g.setColor(darkShadow);                g.drawLine(x+2, y+h-1, x+w-1, y+h-1); // bottom dark shadow                break;            case RIGHT:                g.drawLine(x, y, x+w-3, y); // top highlight                                g.setColor(shadow);                g.drawLine(x, y+h-2, x+w-3, y+h-2); // bottom shadow                g.drawLine(x+w-2, y+2, x+w-2, y+h-3); // right shadow                                g.setColor(darkShadow);                g.drawLine(x+w-2, y+1, x+w-2, y+1); // top-right dark shadow                g.drawLine(x+w-2, y+h-2, x+w-2, y+h-2); // bottom-right dark shadow                g.drawLine(x+w-1, y+2, x+w-1, y+h-3); // right dark shadow                g.drawLine(x, y+h-1, x+w-3, y+h-1); // bottom dark shadow                break;            case BOTTOM:                g.setColor(controlShadow);                g.drawLine(x, y, x, y+h-3); // left highlight                g.drawLine(x+1, y+h-2, x+1, y+h-2); // bottom-left highlight                                //              g.setColor(shadow);                //              g.drawLine(x+2, y+h-2, x+w-3, y+h-2); // bottom shadow                //              g.drawLine(x+w-2, y, x+w-2, y+h-3); // right shadow                                //              g.setColor(darkShadow);                                //                if (isSelected)                g.drawLine(x+2, y+h-1, x+w-3, y+h-1); // bottom dark shadow                //                else                //                  g.drawLine(x+2, y+h, x+w-3, y+h); // bottom dark shadow                                g.drawLine(x+w-2, y+h-2, x+w-2, y+h-2); // bottom-right dark shadow                g.drawLine(x+w-1, y, x+w-1, y+h-3); // right dark shadow                                if (isSelected) {                    Shape _clip = g.getClip();                    Rectangle r = _clip.getBounds();                    g.setClip(r.x, r.y-3, r.x+r.width, r.y-3);                    g.setColor(Color.RED);                    g.drawLine(x+1, y-2, x+w-2, y-2);                    g.setClip(_clip);                }                                break;            case TOP:            default:                g.drawLine(x, y+2, x, y+h-1); // left highlight                g.drawLine(x+1, y+1, x+1, y+1); // top-left highlight                g.drawLine(x+2, y, x+w-3, y); // top highlight                                g.setColor(shadow);                g.drawLine(x+w-2, y+2, x+w-2, y+h-1); // right shadow                                g.setColor(darkShadow);                g.drawLine(x+w-1, y+2, x+w-1, y+h-1); // right dark-shadow                g.drawLine(x+w-2, y+1, x+w-2, y+1); // top-right shadow        }            }        protected void paintTabBackground(Graphics g, int tabPlacement,            int tabIndex,            int x, int y, int w, int h,            boolean isSelected ) {                if (isSelected)            g.setColor(Color.WHITE);        else            g.setColor(selectedColor);                switch(tabPlacement) {                        case LEFT:                g.fillRect(x+1, y+1, w-2, h-3);                break;            case RIGHT:                g.fillRect(x, y+1, w-2, h-3);                break;            case BOTTOM:                g.fillRect(x+1, y, w-3, h-1);                break;            case TOP:            default:                g.fillRect(x+1, y+1, w-3, h-1);                        }            }        protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {        int width = tabPane.getWidth();

⌨️ 快捷键说明

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