Java Code Examples for javax.swing.Painter#paint()

The following examples show how to use javax.swing.Painter#paint() . 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: 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 2
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 3
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 4
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 5
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 6
Source File: TableScrollPaneCorner.java    From Java8CN 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 7
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 8
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 9
Source File: TableScrollPaneCorner.java    From openjdk-jdk8u-backup 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 10
Source File: TableScrollPaneCorner.java    From openjdk-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 11
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 12
Source File: NimbusIcon.java    From hottub 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 13
Source File: NimbusIcon.java    From jdk8u-jdk 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 14
Source File: NimbusIcon.java    From openjdk-jdk9 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<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 15
Source File: NimbusIcon.java    From openjdk-8 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 16
Source File: NimbusIcon.java    From openjdk-jdk8u 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 17
Source File: NimbusIcon.java    From JDKSourceCode1.8 with MIT License 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 18
Source File: NimbusIcon.java    From jdk8u60 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 19
Source File: NimbusIcon.java    From TencentKona-8 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 20
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);
    }
}