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

📄 metalborders.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        protected Color getInactiveBackground()        {            return MetalLookAndFeel.getControlDarkShadow();        }        protected Color getInactiveHighlight()        {            return MetalLookAndFeel.getControlShadow();        }        protected Color getInactiveShadow()        {            return MetalLookAndFeel.getControlInfo();        }        public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)         {            Color background;            Color highlight;            Color shadow;            Window window = SwingUtilities.getWindowAncestor(c);            if (window != null && window.isActive()) {                background = getActiveBackground();                highlight = getActiveHighlight();                shadow = getActiveShadow();            } else {                background = getInactiveBackground();                highlight = getInactiveHighlight();                shadow = getInactiveShadow();            }            g.setColor(background);            // Draw outermost lines            g.drawLine( x + 1, y + 0, x + w-2, y + 0);            g.drawLine( x + 0, y + 1, x + 0, y + h - 2);            g.drawLine( x + w - 1, y + 1, x + w - 1, y + h - 2);            g.drawLine( x + 1, y + h - 1, x + w - 2, y + h - 1);            // Draw the bulk of the border            for (int i = 1; i < 5; i++) {                g.drawRect(x+i,y+i,w-(i*2)-1, h-(i*2)-1);            }            if ((window instanceof Dialog) && ((Dialog) window).isResizable()) {                g.setColor(highlight);                // Draw the Long highlight lines                g.drawLine( corner+1, 3, w-corner, 3);                g.drawLine( 3, corner+1, 3, h-corner);                g.drawLine( w-2, corner+1, w-2, h-corner);                g.drawLine( corner+1, h-2, w-corner, h-2);                g.setColor(shadow);                // Draw the Long shadow lines                g.drawLine( corner, 2, w-corner-1, 2);                g.drawLine( 2, corner, 2, h-corner-1);                g.drawLine( w-3, corner, w-3, h-corner-1);                g.drawLine( corner, h-3, w-corner-1, h-3);            }                    }        public Insets getBorderInsets(Component c)       {            return insets;        }        public Insets getBorderInsets(Component c, Insets newInsets)         {            newInsets.top = insets.top;            newInsets.left = insets.left;            newInsets.bottom = insets.bottom;            newInsets.right = insets.right;            return newInsets;        }    }    /**     * Border for an Error Dialog.     * @since 1.4     */    static class ErrorDialogBorder extends DialogBorder implements UIResource    {        protected Color getActiveBackground() {            return UIManager.getColor("OptionPane.errorDialog.border.background");        }    }        /**     * Border for a QuestionDialog.  Also used for a JFileChooser and a      * JColorChooser..     * @since 1.4     */    static class QuestionDialogBorder extends DialogBorder implements UIResource    {        protected Color getActiveBackground() {            return UIManager.getColor("OptionPane.questionDialog.border.background");        }    }        /**     * Border for a Warning Dialog.     * @since 1.4     */    static class WarningDialogBorder extends DialogBorder implements UIResource    {        protected Color getActiveBackground() {            return UIManager.getColor("OptionPane.warningDialog.border.background");        }    }        /**     * Border for a Palette.     * @since 1.3     */    public static class PaletteBorder extends AbstractBorder implements UIResource {        private static final Insets insets = new Insets(1, 1, 1, 1);        int titleHeight = 0;        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {  	    g.translate(x,y);  	    g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());	    g.drawLine(0, 1, 0, h-2);	    g.drawLine(1, h-1, w-2, h-1);	    g.drawLine(w-1,  1, w-1, h-2);	    g.drawLine( 1, 0, w-2, 0);	    g.drawRect(1,1, w-3, h-3);	    g.translate(-x,-y);      	}        public Insets getBorderInsets(Component c)       {            return insets;        }        public Insets getBorderInsets(Component c, Insets newInsets) {	    newInsets.top = insets.top;	    newInsets.left = insets.left;	    newInsets.bottom = insets.bottom;	    newInsets.right = insets.right;	    return newInsets;	}    }    public static class OptionDialogBorder extends AbstractBorder implements UIResource {        private static final Insets insets = new Insets(3, 3, 3, 3);        int titleHeight = 0;        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {  	    g.translate(x,y);              int messageType = JOptionPane.PLAIN_MESSAGE;            if (c instanceof JInternalFrame) {                Object obj = ((JInternalFrame) c).getClientProperty(                              "JInternalFrame.messageType");                 if (obj != null && (obj instanceof Integer)) {                    messageType = ((Integer) obj).intValue();                }            }            Color borderColor;	    switch (messageType) {            case(JOptionPane.ERROR_MESSAGE):                borderColor = UIManager.getColor(                    "OptionPane.errorDialog.border.background");                break;            case(JOptionPane.QUESTION_MESSAGE):                borderColor = UIManager.getColor(                    "OptionPane.questionDialog.border.background");                break;            case(JOptionPane.WARNING_MESSAGE):                borderColor = UIManager.getColor(                    "OptionPane.warningDialog.border.background");                break;            case(JOptionPane.INFORMATION_MESSAGE):            case(JOptionPane.PLAIN_MESSAGE):            default:                borderColor = MetalLookAndFeel.getPrimaryControlDarkShadow();                break;	    }	    g.setColor(borderColor);              // Draw outermost lines              g.drawLine( 1, 0, w-2, 0);              g.drawLine( 0, 1, 0, h-2);              g.drawLine( w-1, 1, w-1, h-2);              g.drawLine( 1, h-1, w-2, h-1);              // Draw the bulk of the border              for (int i = 1; i < 3; i++) {	          g.drawRect(i, i, w-(i*2)-1, h-(i*2)-1);              }	    g.translate(-x,-y);      	}        public Insets getBorderInsets(Component c)       {            return insets;        }        public Insets getBorderInsets(Component c, Insets newInsets) {	    newInsets.top = insets.top;	    newInsets.left = insets.left;	    newInsets.bottom = insets.bottom;	    newInsets.right = insets.right;	    return newInsets;	}    }    public static class MenuBarBorder extends AbstractBorder implements UIResource {        protected static Insets borderInsets = new Insets( 1, 0, 1, 0 );        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {	    g.translate( x, y );            if (MetalLookAndFeel.usingOcean()) {                // Only paint a border if we're not next to a horizontal                // toolbar                if (!MetalToolBarUI.doesMenuBarBorderToolBar((JMenuBar)c)) {                    g.setColor(MetalLookAndFeel.getControl());                    g.drawLine(0, h - 2, w, h - 2);                    g.setColor(UIManager.getColor("MenuBar.borderColor"));                    g.drawLine(0, h - 1, w, h - 1);                }            }            else {                g.setColor( MetalLookAndFeel.getControlShadow() );                g.drawLine( 0, h-1, w, h-1 );            }	    g.translate( -x, -y );        }        public Insets getBorderInsets( Component c ) {            return getBorderInsets(c, new Insets(0, 0, 0, 0));        }        public Insets getBorderInsets(Component c, Insets newInsets) {            if (MetalLookAndFeel.usingOcean()) {                newInsets.set(0, 0, 2, 0);            }            else {                newInsets.top = borderInsets.top;                newInsets.left = borderInsets.left;                newInsets.bottom = borderInsets.bottom;                newInsets.right = borderInsets.right;            }	    return newInsets;	}    }    public static class MenuItemBorder extends AbstractBorder implements UIResource {        protected static Insets borderInsets = new Insets( 2, 2, 2, 2 );        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {            JMenuItem b = (JMenuItem) c;	    ButtonModel model = b.getModel();	    g.translate( x, y );	    if ( c.getParent() instanceof JMenuBar ) {	        if ( model.isArmed() || model.isSelected() ) {	            g.setColor( MetalLookAndFeel.getControlDarkShadow() );	            g.drawLine( 0, 0, w - 2, 0 );	            g.drawLine( 0, 0, 0, h - 1 );	            g.drawLine( w - 2, 2, w - 2, h - 1 );	            g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );	            g.drawLine( w - 1, 1, w - 1, h - 1 );	            g.setColor( MetalLookAndFeel.getMenuBackground() );	            g.drawLine( w - 1, 0, w - 1, 0 );	        }	    } else {	        if (  model.isArmed() || ( c instanceof JMenu && model.isSelected() ) ) {	            g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );	            g.drawLine( 0, 0, w - 1, 0 );	            g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );	            g.drawLine( 0, h - 1, w - 1, h - 1 );	        } else {	            g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );	            g.drawLine( 0, 0, 0, h - 1 );	        }	    }	    g.translate( -x, -y );        }        public Insets getBorderInsets( Component c ) {            return borderInsets;        }        public Insets getBorderInsets(Component c, Insets newInsets) {	    newInsets.top = borderInsets.top;	    newInsets.left = borderInsets.left;	    newInsets.bottom = borderInsets.bottom;	    newInsets.right = borderInsets.right;	    return newInsets;	}    }    public static class PopupMenuBorder extends AbstractBorder implements UIResource {        protected static Insets borderInsets = new Insets( 3, 1, 2, 1 );        public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {	    g.translate( x, y );            g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );	    g.drawRect( 0, 0, w - 1, h - 1 );            g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );	    g.drawLine( 1, 1, w - 2, 1 );	    g.drawLine( 1, 2, 1, 2 );	    g.drawLine( 1, h - 2, 1, h - 2 );	    g.translate( -x, -y );        }        public Insets getBorderInsets( Component c ) {             return borderInsets;        }        public Insets getBorderInsets(Component c, Insets newInsets) {	    newInsets.top = borderInsets.top;	    newInsets.left = borderInsets.left;	    newInsets.bottom = borderInsets.bottom;	    newInsets.right = borderInsets.right;	    return newInsets;	}    }    public static class RolloverButtonBorder extends ButtonBorder {

⌨️ 快捷键说明

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