1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.vci.client.auth2.component;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
 
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
 
public class RefTextField extends JComponent {
 
    /**
     * 
     */
    private static final long serialVersionUID = -7889775417017928634L;
    private JLabel lable = new JLabel();
    private JTextField text = new JTextField(15);
    private JButton refButton;
    private JPanel parent;
 
    public RefTextField(int x) {
        this.text.setColumns(x);
        if (parent != null)
            doFillIntoGrid(parent);
    }
 
    public RefTextField() {
        if (parent != null)
            doFillIntoGrid(parent);
    }
 
    private void doFillIntoGrid(JPanel parent) {
        parent.setLayout(new GridBagLayout());
        GridBagConstraints g_mpnl = new GridBagConstraints();
        g_mpnl.insets = new Insets(5, 5, 5, 5);
        g_mpnl.anchor = GridBagConstraints.EAST;
        g_mpnl.gridx = 0;
        g_mpnl.gridy = 0;
        parent.add(lable, g_mpnl);
        g_mpnl.gridx = 1;
        parent.add(text, g_mpnl);
        g_mpnl.gridx = 2;
        if (refButton != null) {
            parent.add(refButton, g_mpnl);
        }
    }
 
    public void setLable(String lable) {
        this.lable.setText(lable);
    }
 
    public JButton getRefButton() {
        return refButton;
    }
 
    public void setRefButton(JButton refButton) {
        this.refButton = refButton;
    }
 
    public JPanel getParent() {
        return parent;
    }
 
    public void setParent(JPanel parent) {
        this.parent = parent;
    }
 
    public void updateUI() {
        if (parent != null)
            doFillIntoGrid(parent);
    }
 
    public JLabel getLable() {
        return lable;
    }
 
    public void setLable(JLabel lable) {
        this.lable = lable;
    }
 
    public JTextField getText() {
        return text;
    }
 
    public void setText(String text) {
        this.text.setText(text);
    }
 
}