javax.swing.Painter Java Examples

The following examples show how to use javax.swing.Painter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SynthPainterImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private void paintBackground(SynthContext ctx, Graphics g, int x, int y,
                             int w, int h, AffineTransform transform) {
    // if the background color of the component is 100% transparent
    // then we should not paint any background graphics. This is a solution
    // for there being no way of turning off Nimbus background painting as
    // basic components are all non-opaque by default.
    Component c = ctx.getComponent();
    Color bg = (c != null) ? c.getBackground() : null;
    if (bg == null || bg.getAlpha() > 0){

        Painter<Object> backgroundPainter = style.getBackgroundPainter(ctx);
        if (backgroundPainter != null) {
            paint(backgroundPainter, ctx, g, x, y, w, h,transform);
        }
    }
}
 
Example #2
Source File: TableScrollPaneCorner.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    Painter painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example #3
Source File: TableScrollPaneCorner.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    Painter painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example #4
Source File: TableScrollPaneCorner.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    Painter painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example #5
Source File: TableScrollPaneCorner.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    Painter painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example #6
Source File: TableScrollPaneCorner.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    Painter painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example #7
Source File: NimbusStyle.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets the appropriate foreground Painter, if there is one, for the state
 * specified in the given SynthContext. This method does appropriate
 * fallback searching, as described in #get.
 *
 * @param ctx The SynthContext. Must not be null.
 * @return The foreground painter associated for the given state, or null if
 * none could be found.
 */
public Painter<Object> getForegroundPainter(SynthContext ctx) {
    Values v = getValues(ctx);
    int xstate = getExtendedState(ctx, v);
    Painter<Object> p = null;

    // check the cache
    tmpKey.init("foregroundPainter$$instance", xstate);
    p = paintFilter((Painter)v.cache.get(tmpKey));
    if (p != null) return p;

    // not in cache, so lookup and store in cache
    RuntimeState s = null;
    int[] lastIndex = new int[] {-1};
    while ((s = getNextState(v.states, lastIndex, xstate)) != null) {
        if (s.foregroundPainter != null) {
            p = paintFilter(s.foregroundPainter);
            break;
        }
    }
    if (p == null) p = paintFilter((Painter)get(ctx, "foregroundPainter"));
    if (p != null) {
        v.cache.put(new CacheKey("foregroundPainter$$instance", xstate), p);
    }
    return p;
}
 
Example #8
Source File: NimbusStyle.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets the appropriate background Painter, if there is one, for the state
 * specified in the given SynthContext. This method does appropriate
 * fallback searching, as described in #get.
 *
 * @param ctx The SynthContext. Must not be null.
 * @return The background painter associated for the given state, or null if
 * none could be found.
 */
public Painter<Object> getBackgroundPainter(SynthContext ctx) {
    Values v = getValues(ctx);
    int xstate = getExtendedState(ctx, v);
    Painter<Object> p = null;

    // check the cache
    tmpKey.init("backgroundPainter$$instance", xstate);
    p = paintFilter((Painter)v.cache.get(tmpKey));
    if (p != null) return p;

    // not in cache, so lookup and store in cache
    RuntimeState s = null;
    int[] lastIndex = new int[] {-1};
    while ((s = getNextState(v.states, lastIndex, xstate)) != null) {
        if (s.backgroundPainter != null) {
            p = paintFilter(s.backgroundPainter);
            break;
        }
    }
    if (p == null) p = paintFilter((Painter)get(ctx, "backgroundPainter"));
    if (p != null) {
        v.cache.put(new CacheKey("backgroundPainter$$instance", xstate), p);
    }
    return p;
}
 
Example #9
Source File: TableScrollPaneCorner.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    Painter painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example #10
Source File: SynthPainterImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void paintBackground(SynthContext ctx, Graphics g, int x, int y,
                             int w, int h, AffineTransform transform) {
    // if the background color of the component is 100% transparent
    // then we should not paint any background graphics. This is a solution
    // for there being no way of turning off Nimbus background painting as
    // basic components are all non-opaque by default.
    Component c = ctx.getComponent();
    Color bg = (c != null) ? c.getBackground() : null;
    if (bg == null || bg.getAlpha() > 0){

        Painter<Object> backgroundPainter = style.getBackgroundPainter(ctx);
        if (backgroundPainter != null) {
            paint(backgroundPainter, ctx, g, x, y, w, h,transform);
        }
    }
}
 
Example #11
Source File: TableScrollPaneCorner.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    Painter painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example #12
Source File: NimbusStyle.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the appropriate border Painter, if there is one, for the state
 * specified in the given SynthContext. This method does appropriate
 * fallback searching, as described in #get.
 *
 * @param ctx The SynthContext. Must not be null.
 * @return The border painter associated for the given state, or null if
 * none could be found.
 */
public Painter<Object> getBorderPainter(SynthContext ctx) {
    Values v = getValues(ctx);
    int xstate = getExtendedState(ctx, v);
    Painter<Object> p = null;

    // check the cache
    tmpKey.init("borderPainter$$instance", xstate);
    p = paintFilter((Painter)v.cache.get(tmpKey));
    if (p != null) return p;

    // not in cache, so lookup and store in cache
    RuntimeState s = null;
    int[] lastIndex = new int[] {-1};
    while ((s = getNextState(v.states, lastIndex, xstate)) != null) {
        if (s.borderPainter != null) {
            p = paintFilter(s.borderPainter);
            break;
        }
    }
    if (p == null) p = paintFilter((Painter)get(ctx, "borderPainter"));
    if (p != null) {
        v.cache.put(new CacheKey("borderPainter$$instance", xstate), p);
    }
    return p;
}
 
Example #13
Source File: NimbusStyle.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the appropriate foreground Painter, if there is one, for the state
 * specified in the given SynthContext. This method does appropriate
 * fallback searching, as described in #get.
 *
 * @param ctx The SynthContext. Must not be null.
 * @return The foreground painter associated for the given state, or null if
 * none could be found.
 */
public Painter<Object> getForegroundPainter(SynthContext ctx) {
    Values v = getValues(ctx);
    int xstate = getExtendedState(ctx, v);
    Painter<Object> p = null;

    // check the cache
    tmpKey.init("foregroundPainter$$instance", xstate);
    p = paintFilter((Painter)v.cache.get(tmpKey));
    if (p != null) return p;

    // not in cache, so lookup and store in cache
    RuntimeState s = null;
    int[] lastIndex = new int[] {-1};
    while ((s = getNextState(v.states, lastIndex, xstate)) != null) {
        if (s.foregroundPainter != null) {
            p = paintFilter(s.foregroundPainter);
            break;
        }
    }
    if (p == null) p = paintFilter((Painter)get(ctx, "foregroundPainter"));
    if (p != null) {
        v.cache.put(new CacheKey("foregroundPainter$$instance", xstate), p);
    }
    return p;
}
 
Example #14
Source File: TableScrollPaneCorner.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    Painter painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example #15
Source File: NimbusStyle.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the appropriate background Painter, if there is one, for the state
 * specified in the given SynthContext. This method does appropriate
 * fallback searching, as described in #get.
 *
 * @param ctx The SynthContext. Must not be null.
 * @return The background painter associated for the given state, or null if
 * none could be found.
 */
public Painter<Object> getBackgroundPainter(SynthContext ctx) {
    Values v = getValues(ctx);
    int xstate = getExtendedState(ctx, v);
    Painter<Object> p = null;

    // check the cache
    tmpKey.init("backgroundPainter$$instance", xstate);
    p = paintFilter((Painter)v.cache.get(tmpKey));
    if (p != null) return p;

    // not in cache, so lookup and store in cache
    RuntimeState s = null;
    int[] lastIndex = new int[] {-1};
    while ((s = getNextState(v.states, lastIndex, xstate)) != null) {
        if (s.backgroundPainter != null) {
            p = paintFilter(s.backgroundPainter);
            break;
        }
    }
    if (p == null) p = paintFilter((Painter)get(ctx, "backgroundPainter"));
    if (p != null) {
        v.cache.put(new CacheKey("backgroundPainter$$instance", xstate), p);
    }
    return p;
}
 
Example #16
Source File: TableScrollPaneCorner.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    @SuppressWarnings("unchecked")
    Painter<JComponent> painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example #17
Source File: TableScrollPaneCorner.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    Painter painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example #18
Source File: TableScrollPaneCorner.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Paint the component using the Nimbus Table Header Background Painter
 */
@Override protected void paintComponent(Graphics g) {
    @SuppressWarnings("unchecked")
    Painter<JComponent> painter = (Painter) UIManager.get(
        "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
    if (painter != null){
        if (g instanceof Graphics2D){
            painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
        } else {
            // paint using image to not Graphics2D to support
            // Java 1.1 printing API
            BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
                    BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D)img.getGraphics();
            painter.paint(g2,this,getWidth()+1,getHeight());
            g2.dispose();
            g.drawImage(img,0,0,null);
            img = null;
        }
    }
}
 
Example #19
Source File: SynthPainterImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void paintBackground(SynthContext ctx, Graphics g, int x, int y,
                             int w, int h, AffineTransform transform) {
    // if the background color of the component is 100% transparent
    // then we should not paint any background graphics. This is a solution
    // for there being no way of turning off Nimbus background painting as
    // basic components are all non-opaque by default.
    Component c = ctx.getComponent();
    Color bg = (c != null) ? c.getBackground() : null;
    if (bg == null || bg.getAlpha() > 0){
        Painter backgroundPainter = style.getBackgroundPainter(ctx);
        if (backgroundPainter != null) {
            paint(backgroundPainter, ctx, g, x, y, w, h,transform);
        }
    }
}
 
Example #20
Source File: NimbusStyle.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example #21
Source File: SynthPainterImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private void paintBorder(SynthContext ctx, Graphics g, int x, int y, int w,
                         int h, AffineTransform transform) {
    Painter<Object> borderPainter = style.getBorderPainter(ctx);
    if (borderPainter != null) {
        paint(borderPainter, ctx, g, x, y, w, h,transform);
    }
}
 
Example #22
Source File: NimbusStyle.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private Painter<Object> getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    @SuppressWarnings("unchecked")
    Painter<Object> tmp = (p instanceof Painter ? (Painter)p : null);
    return tmp;
}
 
Example #23
Source File: SynthPainterImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void paintForeground(SynthContext ctx, Graphics g, int x, int y,
                             int w, int h, AffineTransform transform) {
    Painter foregroundPainter = style.getForegroundPainter(ctx);
    if (foregroundPainter != null) {
        paint(foregroundPainter, ctx, g, x, y, w, h,transform);
    }
}
 
Example #24
Source File: NimbusStyle.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example #25
Source File: NimbusStyle.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private Painter getPainter(Map<String, Object> defaults, String key) {
    Object p = defaults.get(key);
    if (p instanceof UIDefaults.LazyValue) {
        p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
    }
    return (p instanceof Painter ? (Painter)p : null);
}
 
Example #26
Source File: NimbusIcon.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Implements the standard Icon interface's paintIcon method as the standard
 * synth stub passes null for the context and this will cause us to not
 * paint any thing, so we override here so that we can paint the enabled
 * state if no synth context is available
 */
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    Painter painter = (Painter)UIManager.get(prefix + "[Enabled]." + key);
    if (painter != null){
        JComponent jc = (c instanceof JComponent) ? (JComponent)c : null;
        Graphics2D gfx = (Graphics2D)g;
        gfx.translate(x, y);
        painter.paint(gfx, jc , width, height);
        gfx.translate(-x, -y);
    }
}
 
Example #27
Source File: NimbusIcon.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Implements the standard Icon interface's paintIcon method as the standard
 * synth stub passes null for the context and this will cause us to not
 * paint any thing, so we override here so that we can paint the enabled
 * state if no synth context is available
 */
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    Painter<JComponent> painter =
        paintFilter((Painter)UIManager.get(prefix + "[Enabled]." + key));
    if (painter != null){
        JComponent jc = (c instanceof JComponent) ? (JComponent)c : null;
        Graphics2D gfx = (Graphics2D)g;
        gfx.translate(x, y);
        painter.paint(gfx, jc , width, height);
        gfx.translate(-x, -y);
    }
}
 
Example #28
Source File: SynthPainterImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void paintBorder(SynthContext ctx, Graphics g, int x, int y, int w,
                         int h, AffineTransform transform) {
    Painter borderPainter = style.getBorderPainter(ctx);
    if (borderPainter != null) {
        paint(borderPainter, ctx, g, x, y, w, h,transform);
    }
}
 
Example #29
Source File: SynthPainterImpl.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private void paintBorder(SynthContext ctx, Graphics g, int x, int y, int w,
                         int h, AffineTransform transform) {
    Painter borderPainter = style.getBorderPainter(ctx);
    if (borderPainter != null) {
        paint(borderPainter, ctx, g, x, y, w, h,transform);
    }
}
 
Example #30
Source File: NimbusIcon.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Implements the standard Icon interface's paintIcon method as the standard
 * synth stub passes null for the context and this will cause us to not
 * paint any thing, so we override here so that we can paint the enabled
 * state if no synth context is available
 */
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    Painter painter = (Painter)UIManager.get(prefix + "[Enabled]." + key);
    if (painter != null){
        JComponent jc = (c instanceof JComponent) ? (JComponent)c : null;
        Graphics2D gfx = (Graphics2D)g;
        gfx.translate(x, y);
        painter.paint(gfx, jc , width, height);
        gfx.translate(-x, -y);
    }
}