KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > nimbus > TableScrollPaneCorner


1 /*
2  * @(#)TableScrollPaneCorner.java 1.3 08/01/29
3  *
4  * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package com.sun.java.swing.plaf.nimbus;
8
9 import com.sun.java.swing.Painter;
10
11 import javax.swing.JComponent JavaDoc;
12 import javax.swing.UIManager JavaDoc;
13 import javax.swing.plaf.UIResource JavaDoc;
14 import java.awt.Graphics JavaDoc;
15 import java.awt.Graphics2D JavaDoc;
16 import java.awt.Color JavaDoc;
17 import java.awt.image.BufferedImage JavaDoc;
18
19 /**
20  * TableScrollPaneCorner - A simple component that paints itself using the table
21  * header background painter. It is used to fill the top right corner of
22  * scrollpane.
23  *
24  * @author Created by Jasper Potts (Jan 28, 2008)
25  */

26 public class TableScrollPaneCorner extends JComponent JavaDoc implements UIResource JavaDoc{
27
28     /**
29      * Paint the component using the Nimbus Table Header Background Painter
30      */

31     @Override JavaDoc protected void paintComponent(Graphics JavaDoc g) {
32         Painter painter = (Painter) UIManager.get(
33             "TableHeader:\"TableHeader.renderer\"[Enabled].backgroundPainter");
34         if (painter != null){
35             if (g instanceof Graphics2D JavaDoc){
36                 painter.paint((Graphics2D JavaDoc)g,this,getWidth()+1,getHeight());
37             } else {
38                 // paint using image to not Graphics2D to support
39
// Java 1.1 printing API
40
BufferedImage JavaDoc img = new BufferedImage JavaDoc(getWidth(),getHeight(),
41                         BufferedImage.TYPE_INT_ARGB);
42                 Graphics2D JavaDoc g2 = (Graphics2D JavaDoc)img.getGraphics();
43                 painter.paint(g2,this,getWidth()+1,getHeight());
44                 g2.dispose();
45                 g.drawImage(img,0,0,null);
46                 img = null;
47             }
48         }
49     }
50 }
51
Popular Tags