01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.x.impl.swing;
14:
15: import java.awt.Color;
16:
17: import javax.swing.BorderFactory;
18: import javax.swing.JComponent;
19: import javax.swing.JScrollPane;
20: import javax.swing.JTextArea;
21:
22: import com.eviware.x.form.XFormTextField;
23:
24: public class JTextAreaFormField extends
25: AbstractSwingXFormField<JComponent> implements XFormTextField {
26: private JScrollPane scrollPane;
27:
28: public JTextAreaFormField() {
29: super (new JTextArea());
30:
31: scrollPane = new JScrollPane(super .getComponent());
32: }
33:
34: public void setRequired(boolean required, String message) {
35: super .setRequired(required, message);
36:
37: if (required)
38: getComponent().setBorder(
39: BorderFactory.createCompoundBorder(BorderFactory
40: .createLineBorder(Color.RED), BorderFactory
41: .createEmptyBorder(2, 2, 2, 2)));
42: else
43: getComponent().setBorder(
44: BorderFactory
45: .createCompoundBorder(BorderFactory
46: .createLineBorder(Color.GRAY),
47: BorderFactory.createEmptyBorder(2,
48: 2, 2, 2)));
49: }
50:
51: public JTextArea getTextArea() {
52: return (JTextArea) super .getComponent();
53: }
54:
55: public JComponent getComponent() {
56: return scrollPane;
57: }
58:
59: public void setValue(String value) {
60: getTextArea().setText(value);
61: }
62:
63: public String getValue() {
64: return getTextArea().getText();
65: }
66:
67: public void setWidth(int columns) {
68: getTextArea().setColumns(columns);
69: }
70:
71: @Override
72: public boolean isMultiRow() {
73: return true;
74: }
75: }
|