src/share/classes/javax/swing/plaf/nimbus/TableScrollPaneCorner.java

Print this page




  31 import javax.swing.plaf.UIResource;
  32 import java.awt.Graphics;
  33 import java.awt.Graphics2D;
  34 import java.awt.Color;
  35 import java.awt.image.BufferedImage;
  36 
  37 /**
  38  * TableScrollPaneCorner - A simple component that paints itself using the table
  39  * header background painter. It is used to fill the top right corner of
  40  * scrollpane.
  41  *
  42  * @author Created by Jasper Potts (Jan 28, 2008)
  43  */
  44 @SuppressWarnings("serial") // Superclass is not serializable across versions
  45 class TableScrollPaneCorner extends JComponent implements UIResource{
  46 
  47     /**
  48      * Paint the component using the Nimbus Table Header Background Painter
  49      */
  50     @Override protected void paintComponent(Graphics g) {
  51         Painter painter = (Painter) UIManager.get(

  52             "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
  53         if (painter != null){
  54             if (g instanceof Graphics2D){
  55                 painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
  56             } else {
  57                 // paint using image to not Graphics2D to support
  58                 // Java 1.1 printing API
  59                 BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
  60                         BufferedImage.TYPE_INT_ARGB);
  61                 Graphics2D g2 = (Graphics2D)img.getGraphics();
  62                 painter.paint(g2,this,getWidth()+1,getHeight());
  63                 g2.dispose();
  64                 g.drawImage(img,0,0,null);
  65                 img = null;
  66             }
  67         }
  68     }
  69 }


  31 import javax.swing.plaf.UIResource;
  32 import java.awt.Graphics;
  33 import java.awt.Graphics2D;
  34 import java.awt.Color;
  35 import java.awt.image.BufferedImage;
  36 
  37 /**
  38  * TableScrollPaneCorner - A simple component that paints itself using the table
  39  * header background painter. It is used to fill the top right corner of
  40  * scrollpane.
  41  *
  42  * @author Created by Jasper Potts (Jan 28, 2008)
  43  */
  44 @SuppressWarnings("serial") // Superclass is not serializable across versions
  45 class TableScrollPaneCorner extends JComponent implements UIResource{
  46 
  47     /**
  48      * Paint the component using the Nimbus Table Header Background Painter
  49      */
  50     @Override protected void paintComponent(Graphics g) {
  51         @SuppressWarnings("unchecked")
  52         Painter<JComponent> painter = (Painter) UIManager.get(
  53             "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
  54         if (painter != null){
  55             if (g instanceof Graphics2D){
  56                 painter.paint((Graphics2D)g,this,getWidth()+1,getHeight());
  57             } else {
  58                 // paint using image to not Graphics2D to support
  59                 // Java 1.1 printing API
  60                 BufferedImage img =  new BufferedImage(getWidth(),getHeight(),
  61                         BufferedImage.TYPE_INT_ARGB);
  62                 Graphics2D g2 = (Graphics2D)img.getGraphics();
  63                 painter.paint(g2,this,getWidth()+1,getHeight());
  64                 g2.dispose();
  65                 g.drawImage(img,0,0,null);
  66                 img = null;
  67             }
  68         }
  69     }
  70 }