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.JPasswordField;
19:
20: import com.eviware.x.form.XFormTextField;
21:
22: public class JPasswordFieldFormField extends
23: AbstractSwingXFormField<JPasswordField> implements
24: XFormTextField {
25: public JPasswordFieldFormField() {
26: super (new JPasswordField());
27: }
28:
29: public void setRequired(boolean required, String message) {
30: super .setRequired(required, message);
31:
32: if (required)
33: getComponent().setBorder(
34: BorderFactory.createCompoundBorder(BorderFactory
35: .createLineBorder(Color.RED), BorderFactory
36: .createEmptyBorder(2, 2, 2, 2)));
37: else
38: getComponent().setBorder(
39: BorderFactory
40: .createCompoundBorder(BorderFactory
41: .createLineBorder(Color.GRAY),
42: BorderFactory.createEmptyBorder(2,
43: 2, 2, 2)));
44: }
45:
46: public void setValue(String value) {
47: getComponent().setText(value);
48: }
49:
50: public String getValue() {
51: return new String(getComponent().getPassword());
52: }
53:
54: public void setWidth(int columns) {
55: getComponent().setColumns(columns);
56: }
57: }
|