01: package net.xoetrope.swing;
02:
03: import javax.swing.JTextArea;
04:
05: import net.xoetrope.xui.XTextHolder;
06: import net.xoetrope.xui.XAttributedComponent;
07: import javax.swing.BorderFactory;
08: import java.awt.SystemColor;
09:
10: /**
11: * <p>A wrapper for the JTextArea class</p>
12: * <p>Copyright (c) Xoetrope Ltd., 1998-2003<br>
13: * License: see license.txt
14: * @version $Revision: 1.4 $
15: */
16: public class XTextArea extends JTextArea implements XTextHolder,
17: XAttributedComponent {
18: public XTextArea() {
19: }
20:
21: /**
22: * Set one or more attributes of the component. Currently this handles the
23: * attributes
24: * @param attribName the attribute name
25: * @param attribValue the attribute value
26: * <OL>
27: * <LI>rows, value=number of rows</LI>
28: * <LI>cols, value=number of columns</LI>
29: * <LI>wrap, value=true|false turns wrapping on or off</LI>
30: * <LI>wordwrap, value=true|false turns wrapping at word breaks on or off</LI>
31: * </OL>
32: */
33: public void setAttribute(String attribName, String attribValue) {
34: String attribNameLwr = attribName.toLowerCase();
35: boolean bAttribValue = attribValue.equalsIgnoreCase("true");
36: if (attribNameLwr.compareTo("rows") == 0)
37: setRows(Integer.parseInt(attribValue));
38: else if (attribNameLwr.compareTo("columns") == 0)
39: setColumns(Integer.parseInt(attribValue));
40: else if (attribNameLwr.compareTo("wrap") == 0)
41: setLineWrap(bAttribValue);
42: else if (attribNameLwr.compareTo("wordwrap") == 0)
43: setWrapStyleWord(bAttribValue);
44: else if (attribNameLwr.compareTo("border") == 0)
45: setBorder(BorderFactory
46: .createLineBorder(SystemColor.controlDkShadow));
47: }
48: }
|