001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.window.quickhelp;
020:
021: import java.awt.Color;
022: import java.awt.Component;
023: import java.awt.Font;
024:
025: import javax.swing.BorderFactory;
026: import javax.swing.Icon;
027: import javax.swing.JLabel;
028: import javax.swing.JList;
029: import javax.swing.ListCellRenderer;
030:
031: import org.openharmonise.him.window.quickhelp.QuickHelpWindow.*;
032:
033: /**
034: *
035: * @author Matthew Large
036: * @version $Revision: 1.1 $
037: *
038: */
039: public class HelpListCellRenderer extends JLabel implements
040: ListCellRenderer {
041:
042: private Color m_selectedColor = new Color(173, 169, 143);
043:
044: /**
045: *
046: */
047: public HelpListCellRenderer() {
048: super ();
049: this .setOpaque(true);
050: String fontName = "Dialog";
051: int fontSize = 11;
052: Font font = new Font(fontName, Font.PLAIN, fontSize);
053: this .setFont(font);
054: }
055:
056: /* (non-Javadoc)
057: * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
058: */
059: public Component getListCellRendererComponent(JList list,
060: Object value, int index, boolean bIsSelected,
061: boolean bCellHasFocus) {
062:
063: QuickHelpWindow.HelpListItem listItem = (HelpListItem) value;
064:
065: StringBuffer sBuff = new StringBuffer();
066: for (int i = 0; i < listItem.getDepth(); i++) {
067: sBuff.append(" ");
068: }
069: sBuff.append(listItem.getTitle());
070: this .setText(sBuff.toString());
071: if (bIsSelected) {
072: this .setBorder(BorderFactory.createLineBorder(Color.BLACK,
073: 2));
074: this .setBackground(m_selectedColor);
075: } else {
076: this .setBorder(BorderFactory.createLineBorder(Color.WHITE,
077: 2));
078: this .setBackground(Color.WHITE);
079: }
080:
081: return this ;
082: }
083:
084: /**
085: * @param arg0
086: */
087: private HelpListCellRenderer(String arg0) {
088: super (arg0);
089: }
090:
091: /**
092: * @param arg0
093: * @param arg1
094: */
095: private HelpListCellRenderer(String arg0, int arg1) {
096: super (arg0, arg1);
097: }
098:
099: /**
100: * @param arg0
101: */
102: private HelpListCellRenderer(Icon arg0) {
103: super (arg0);
104: }
105:
106: /**
107: * @param arg0
108: * @param arg1
109: */
110: private HelpListCellRenderer(Icon arg0, int arg1) {
111: super (arg0, arg1);
112: }
113:
114: /**
115: * @param arg0
116: * @param arg1
117: * @param arg2
118: */
119: private HelpListCellRenderer(String arg0, Icon arg1, int arg2) {
120: super(arg0, arg1, arg2);
121: }
122:
123: }
|