1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package fr.ens.transcriptome.doelan.gui;
23
24 import java.awt.GridBagConstraints;
25
26 import javax.swing.JLabel;
27 import javax.swing.JPanel;
28 import javax.swing.JTextField;
29
30 /***
31 * This class implements a file chooser.
32 * @author Laurent Jourdren
33 */
34 public class DescriptionWidget {
35
36 private String label;
37 private JPanel jPanel;
38 private int position;
39 private int mnemonicKey;
40
41 private JTextField descriptionField = new JTextField();
42
43
44
45
46
47 /***
48 * Get the text of the label.
49 * @return Returns the labelText
50 */
51 private String getLabel() {
52 return label;
53 }
54
55 /***
56 * Get the panel.
57 * @return Returns the Panel
58 */
59 private JPanel getPanel() {
60 return jPanel;
61 }
62
63 /***
64 * Get the position in the panel.
65 * @return Returns the position
66 */
67 private int getPosition() {
68 return position;
69 }
70
71 /***
72 * Get the mnemonic key.
73 * @return Returns the mnemonicKey
74 */
75 public int getMnemonicKey() {
76 return mnemonicKey;
77 }
78
79 /***
80 * Get the text of the description.
81 * @return the text of the description
82 */
83 public String getDescription() {
84 return this.descriptionField.getText();
85 }
86
87
88
89
90
91 /***
92 * Set the label of the text.
93 * @param labelText The labelText to set
94 */
95 private void setLabel(final String labelText) {
96 this.label = labelText;
97 }
98
99 /***
100 * Set the panel.
101 * @param panel The Panel to set
102 */
103 private void setPanel(final JPanel panel) {
104 jPanel = panel;
105 }
106
107 /***
108 * Set the postion in the panel.
109 * @param position The position to set
110 */
111 private void setPosition(final int position) {
112 this.position = position;
113 }
114
115 /***
116 * set the mnemonic key.
117 * @param mnemonicKey The mnemonicKey to set
118 */
119 public void setMnemonicKey(final int mnemonicKey) {
120 this.mnemonicKey = mnemonicKey;
121 }
122
123
124
125
126
127 private void init() {
128
129 GridBagConstraints gridBagConstraints;
130
131
132 final JPanel selectorPanel = getPanel();
133
134
135 JLabel jLabel1 = new JLabel(getLabel());
136 gridBagConstraints = new java.awt.GridBagConstraints();
137 gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
138 gridBagConstraints.gridx = 0;
139 gridBagConstraints.gridy = getPosition();
140 gridBagConstraints.ipadx = 30;
141 selectorPanel.add(jLabel1, gridBagConstraints);
142 jLabel1.setDisplayedMnemonic(getMnemonicKey());
143 jLabel1.setLabelFor(descriptionField);
144
145
146 gridBagConstraints = new java.awt.GridBagConstraints();
147 gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
148 gridBagConstraints.gridx = 1;
149 gridBagConstraints.gridwidth = 4;
150 gridBagConstraints.gridy = getPosition();
151 selectorPanel.add(descriptionField, gridBagConstraints);
152
153 }
154
155
156
157
158
159 /***
160 * Public constructor.
161 * @param label the Label of the widget
162 * @param panel Calling panel
163 * @param position Position of the chooser
164 */
165 public DescriptionWidget(final String label, final int mnemonicKey,
166 final JPanel panel, final int position) {
167
168 setLabel(label);
169 setMnemonicKey(mnemonicKey);
170 setPanel(panel);
171 setPosition(position);
172 init();
173 }
174
175 }