1 32 33 package it.businesslogic.ireport.gui.style; 34 35 import java.awt.Color ; 36 import java.awt.Graphics ; 37 import java.awt.Image ; 38 import java.awt.Rectangle ; 39 import javax.swing.DefaultListCellRenderer ; 40 import javax.swing.JList ; 41 42 46 public class JBGList extends JList { 47 48 private boolean showLibrary = true; 49 52 public static Image backGround = (new javax.swing.ImageIcon (JBGList.class.getResource("/it/businesslogic/ireport/icons/styles/library.png"))).getImage() ; 53 public static Image backGroundDocument = (new javax.swing.ImageIcon (JBGList.class.getResource("/it/businesslogic/ireport/icons/styles/document.png"))).getImage() ; 54 55 public JBGList() { 56 super(); 57 this.setCellRenderer(new StyleCellRenderer()); 58 ((DefaultListCellRenderer )this.getCellRenderer()).setOpaque(false); 59 } 60 61 62 public void paint(Graphics g) 63 { 64 65 Rectangle r = this.getVisibleRect(); 66 g.setColor(Color.WHITE); 67 g.fillRect((int)r.getX(), (int)r.getY(), (int)r.getWidth(),(int)r.getHeight()); 68 g.drawImage( (isShowLibrary()) ? backGround : backGroundDocument, (int)r.getX()+(int)r.getWidth()-109,(int)r.getY()+(int)r.getHeight()-106,109,106,this); 69 super.paint(g); 70 71 } 72 73 public boolean isShowLibrary() { 74 return showLibrary; 75 } 76 77 public void setShowLibrary(boolean newShowLibrary) { 78 if (showLibrary == newShowLibrary) return; 79 this.showLibrary = newShowLibrary; 80 this.repaint(); 81 } 82 83 } 84 | Popular Tags |