001 /* 002 // $Id: //open/mondrian/src/main/mondrian/gui/ListRenderer.java#1 $ 003 // This software is subject to the terms of the Common Public License 004 // Agreement, available at the following URL: 005 // http://www.opensource.org/licenses/cpl.html. 006 // Copyright (C) 2002-2007 Julian Hyde and others 007 // All Rights Reserved. 008 // You must accept the terms of that agreement to use this software. 009 */ 010 package mondrian.gui; 011 012 import javax.swing.*; 013 import java.awt.*; 014 015 /** 016 * <code>ListRenderer</code> ... 017 * 018 * @version $Id: //open/mondrian/src/main/mondrian/gui/ListRenderer.java#1 $ 019 */ 020 class ListRenderer implements ListCellRenderer { 021 // The original ListCellRenderer we want to override 022 ListCellRenderer std; 023 024 public ListRenderer(ListCellRenderer override) { 025 if (override == null) { 026 throw new NullPointerException( 027 "ListRenderer constructor: default renderer is null"); 028 } 029 std = override; 030 } 031 032 // Override of getListCellRendererComponent. 033 // This is called by the AWT event thread to paint components. 034 public Component getListCellRendererComponent(JList list, 035 Object value, 036 int index, 037 boolean isSelected, 038 boolean cellHasFocus) { 039 // Ask the standard renderer for what it thinks is right 040 Component c = std.getListCellRendererComponent(list, 041 value, 042 index, 043 isSelected, 044 cellHasFocus); 045 if (!isSelected) { 046 // Set the background of the returned component to Aqua 047 // striped background, but only for unselected cells; 048 // The standard renderer functions as desired for 049 // highlighted cells. 050 c.setBackground((Color)UIManager.get("ComboBox.background")); 051 } 052 return c; 053 } 054 } 055 056 // End ListRenderer.java