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

📄 flatsplitpanedivider.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                JSplitPane splitPane = getSplitPaneFromSuper();                if(splitPane != null) {                    int         oneTouchSize = getOneTouchSizeFromSuper();                    int         orientation = getOrientationFromSuper();                    int         blockSize = Math.min(getDividerSize(),                    oneTouchSize);                                        // Initialize the color array                    Color[]     colors = {                        this.getBackground(),                        MetalLookAndFeel.getPrimaryControlDarkShadow(),                        MetalLookAndFeel.getPrimaryControlInfo(),                        MetalLookAndFeel.getPrimaryControlHighlight()};                                                // Fill the background first ...                        g.setColor(this.getBackground());                        g.fillRect(0, 0, this.getWidth(),                        this.getHeight());                                                // ... then draw the arrow.                        if (getModel().isPressed()) {                            // Adjust color mapping for pressed button state                            colors[1] = colors[2];                        }                        if(orientation == JSplitPane.VERTICAL_SPLIT) {                            // Draw the image for a vertical split                            for (int i=1; i<=buffer[0].length; i++) {                                for (int j=1; j<blockSize; j++) {                                    if (buffer[j-1][i-1] == 0) {                                        continue;                                    }                                    else {                                        g.setColor(                                        colors[buffer[j-1][i-1]]);                                    }                                    g.drawLine(i, j, i, j);                                }                            }                        }                        else {                            // Draw the image for a horizontal split                            // by simply swaping the i and j axis.                            // Except the drawLine() call this code is                            // identical to the code block above. This was done                            // in order to remove the additional orientation                            // check for each pixel.                            for (int i=1; i<=buffer[0].length; i++) {                                for (int j=1; j<blockSize; j++) {                                    if (buffer[j-1][i-1] == 0) {                                        // Nothing needs                                        // to be drawn                                        continue;                                    }                                    else {                                        // Set the color from the                                        // color map                                        g.setColor(                                        colors[buffer[j-1][i-1]]);                                    }                                    // Draw a pixel                                    g.drawLine(j, i, j, i);                                }                            }                        }                }            }                        // Don't want the button to participate in focus traversable.            public boolean isFocusTraversable() {                return false;            }        };                b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));        b.setFocusPainted(false);        b.setBorderPainted(false);        b.setRequestFocusEnabled(false);        return b;    }        /**     * Used to layout a MetalSplitPaneDivider. Layout for the divider     * involves appropriately moving the left/right buttons around.     * <p>     * This inner class is marked &quot;public&quot; due to a compiler bug.     * This class should be treated as a &quot;protected&quot; inner class.     * Instantiate it only within subclasses of MetalSplitPaneDivider.     */    public class FlapSplitPaneDividerLayout implements LayoutManager {                public void layoutContainer(Container c) {                        JButton     leftButton = getLeftButtonFromSuper();            JButton     rightButton = getRightButtonFromSuper();            JSplitPane  splitPane = getSplitPaneFromSuper();            int         orientation = getOrientationFromSuper();            int         oneTouchSize = getOneTouchSizeFromSuper();            int         oneTouchOffset = getOneTouchOffsetFromSuper();            Insets      insets = getInsets();                        // This layout differs from the one used in BasicSplitPaneDivider.            // It does not center justify the oneTouchExpadable buttons.            // This was necessary in order to meet the spec of the Metal            // splitpane divider.            if (leftButton != null && rightButton != null &&            c == FlatSplitPaneDivider.this) {                                if (splitPane.isOneTouchExpandable()) {                                        if (orientation == JSplitPane.VERTICAL_SPLIT) {                        int extraY = (insets != null) ? insets.top : 0;                        int blockSize = getDividerSize();                                                if (insets != null) {                            blockSize -= (insets.top + insets.bottom);                        }                        extraY = 2;                        blockSize = Math.min(blockSize, oneTouchSize);                        leftButton.setBounds(oneTouchOffset, extraY,                        blockSize * 2, blockSize);                        rightButton.setBounds(oneTouchOffset +                        oneTouchSize * 2, extraY,                        blockSize * 2, blockSize);                    }                                        else {                        int blockSize = getDividerSize();                        int extraX = (insets != null) ? insets.left : 0;                                                if (insets != null) {                            blockSize -= (insets.left + insets.right);                        }                                                blockSize = Math.min(blockSize, oneTouchSize);                        leftButton.setBounds(extraX, oneTouchOffset,                        blockSize, blockSize * 2);                        rightButton.setBounds(extraX, oneTouchOffset +                        oneTouchSize * 2, blockSize,                        blockSize * 2);                    }                                    }                                else {                    leftButton.setBounds(-5, -5, 1, 1);                    rightButton.setBounds(-5, -5, 1, 1);                }            }                    }                public Dimension minimumLayoutSize(Container c) {            return new Dimension(0,0);        }                public Dimension preferredLayoutSize(Container c) {            return new Dimension(0, 0);        }                public void removeLayoutComponent(Component c) {}                public void addLayoutComponent(String string, Component c) {}    }      /*   * The following methods only exist in order to be able to access protected   * members in the superclass, because these are otherwise not available   * in any inner class.   */        int getOneTouchSizeFromSuper() {        return super.ONE_TOUCH_SIZE;    }        int getOneTouchOffsetFromSuper() {        return super.ONE_TOUCH_OFFSET;    }        int getOrientationFromSuper() {        return super.orientation;    }        JSplitPane getSplitPaneFromSuper() {        return super.splitPane;    }        JButton getLeftButtonFromSuper() {        return super.leftButton;    }        JButton getRightButtonFromSuper() {        return super.rightButton;    }}

⌨️ 快捷键说明

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