001/* ---------------------------------------------------------------------------- 002 The Kiwi Toolkit - A Java Class Library 003 Copyright (C) 1998-2004 Mark A. Lindner 004 005 This library is free software; you can redistribute it and/or 006 modify it under the terms of the GNU General Public License as 007 published by the Free Software Foundation; either version 2 of the 008 License, or (at your option) any later version. 009 010 This library is distributed in the hope that it will be useful, 011 but WITHOUT ANY WARRANTY; without even the implied warranty of 012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 General Public License for more details. 014 015 You should have received a copy of the GNU General Public License 016 along with this library; if not, write to the Free Software 017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 018 02111-1307, USA. 019 020 The author may be contacted at: mark_a_lindner@yahoo.com 021 ---------------------------------------------------------------------------- 022 $Log: KLabelArea.java,v $ 023 Revision 1.4 2004/05/12 18:57:32 markl 024 comment block updates 025 026 Revision 1.3 2004/01/23 00:03:58 markl 027 javadoc corrections 028 029 Revision 1.2 2003/01/19 09:50:53 markl 030 Javadoc & comment header updates. 031 032 Revision 1.1 2001/03/12 09:27:18 markl 033 Renamed from KLabel. 034 035 Revision 1.7 1999/07/05 08:19:56 markl 036 Made not focus traversable. 037 038 Revision 1.6 1999/06/28 08:17:08 markl 039 Fixed font. 040 041 Revision 1.5 1999/06/14 00:50:52 markl 042 Fixed font to be 12 point, not 10. 043 044 Revision 1.4 1999/06/03 08:06:48 markl 045 Added import statement. 046 047 Revision 1.3 1999/06/03 06:17:40 markl 048 Rewritten to extend JTextArea; other implementation had problems. 049 050 Revision 1.2 1999/02/28 11:44:08 markl 051 Minor fixes. 052 ---------------------------------------------------------------------------- 053*/ 054 055package kiwi.ui; 056 057import java.awt.*; 058import java.util.*; 059import javax.swing.*; 060import javax.swing.plaf.ComponentUI; 061 062import kiwi.util.*; 063 064/** A multi-line label. This class renders a string as one or more lines, 065 * breaking text on whitespace and producing a left-justified paragraph. This 066 * class is basically a <code>JTextArea</code> that is transparent, non- 067 * editable, non-scrollable, and non-highlightable. 068 * 069 * <p><center> 070 * <img src="snapshot/KLabelArea.gif"><br> 071 * <i>An example KLabelArea.</i> 072 * </center> 073 * 074 * @since Kiwi 1.3 075 * 076 * @author Mark Lindner 077 */ 078 079public class KLabelArea extends JTextArea 080 { 081 /** Construct a new <code>KLabelArea</code> with the specified text and rows 082 * and columns. 083 * 084 * @param text The text to display. 085 * @param rows The height of the label in rows. 086 * @param cols The width of the label in columns. 087 */ 088 089 public KLabelArea(String text, int rows, int cols) 090 { 091 super(text, rows, cols); 092 093 _init(); 094 } 095 096 /** Construct a new <code>KLabelArea</code> with the specified number of 097 * rows and columns. 098 * 099 * @param rows The height of the label in rows. 100 * @param cols The width of the label in columns. 101 */ 102 103 public KLabelArea(int rows, int cols) 104 { 105 super(rows, cols); 106 107 _init(); 108 } 109 110 /* initialize component */ 111 112 private void _init() 113 { 114 setEditable(false); 115 setOpaque(false); 116 setHighlighter(null); 117 setFont(KiwiUtils.boldFont); 118 setLineWrap(true); 119 setWrapStyleWord(true); 120 } 121 122 /* The following are overridden to counteract Swing bugs. */ 123 124 public void setUI(ComponentUI newUI) 125 { 126 super.setUI(newUI); 127 _init(); 128 } 129 130 public void updateUI() 131 { 132 super.updateUI(); 133 _init(); 134 } 135 136 /** Overridden to return <code>false</code>. 137 */ 138 139 public final boolean isFocusable() 140 { 141 return(false); 142 } 143 144 } 145 146/* end of source file */