/Users/lyon/j4p/src/gui/run/RunLabelPasswordFieldPanel.java
|
1 package gui.run;
2
3 import javax.swing.BoxLayout;
4 import javax.swing.JPanel;
5 import java.awt.BorderLayout;
6 import java.awt.Container;
7 import java.awt.GridLayout;
8
9 /**
10 * DocJava, Inc. http://www.docjava.com
11 * Programmer: dlyon Date: Mar 31, 2004 Time:
12 * 7:36:31 PM
13 */
14 public class RunLabelPasswordFieldPanel extends JPanel {
15 public RunLabelPasswordFieldPanel(
16 RunPasswordField tf) {
17 setLayout(
18 new BoxLayout(this,
19 BoxLayout.Y_AXIS));
20 //setLayout(new javax.swing.ScrollPaneLayout());
21 add(tf, BorderLayout.CENTER);
22 add(getLabel(tf), BorderLayout.WEST);
23 }
24
25 private RunLabel getLabel(
26 RunPasswordField tf) {
27 RunLabel rl = new RunLabel(
28 new String(tf.getPassword()));
29 tf.setText("");
30 return rl;
31 }
32
33 public static void main(String args[]) {
34 gui.ClosableJFrame cf = new gui.ClosableJFrame(
35 "RunPasswordField");
36 Container c = cf.getContentPane();
37 c.add(new RunLabelPasswordFieldPanel(new RunPasswordField(
38 "[Name") {
39 public void run() {
40 System.out.println(getPassword());
41 }
42 }));
43 c.add(new RunLabelPasswordFieldPanel(new RunPasswordField(
44 "[House/Street") {
45 public void run() {
46 System.out.println(getPassword());
47 }
48 }));
49 RunLabelPasswordFieldPanel runLabelPasswordFieldPanel
50 = new RunLabelPasswordFieldPanel(new RunPasswordField(
51 "[City") {
52 public void run() {
53 System.out.println(getPassword());
54 }
55 });
56 c.add(runLabelPasswordFieldPanel);
57 runLabelPasswordFieldPanel.invalidate();
58 c.setLayout(new GridLayout(4, 0));
59 c.invalidate();
60 cf.setSize(200, 200);
61 cf.setVisible(true);
62 }
63 }
64