Java Reference
In-Depth Information
73 dialog.setVisible(false); // go away
74 }
75 });
76
77 JButton cancelButton = new JButton("Cancel");
78 cancelButton.addActionListener(new ActionListener() {
79 public void actionPerformed(ActionEvent e) {
80 clear(); // toss out any entry
81 dialog.setVisible(false);
82 }
83 });
84 getRootPane().setDefaultButton(createButton);
85
86 JPanel closePanel = new JPanel();
87 closePanel.setLayout(new BoxLayout(closePanel, BoxLayout.LINE_AXIS));
88 closePanel.add(Box.createHorizontalGlue());
89 closePanel.add(createButton);
90 closePanel.add(Box.createRigidArea(new Dimension(5, 0)));
91 closePanel.add(cancelButton);
92 closePanel.setBorder(BorderFactory.createEmptyBorder(10,0,5,5));
93
94 JPanel contentPane = new JPanel(new BorderLayout());
95 contentPane.add(label, BorderLayout.PAGE_START);
96 contentPane.add(textes, BorderLayout.CENTER);
97 contentPane.add(closePanel, BorderLayout.PAGE_END);
98 contentPane.setOpaque(true);
99 setContentPane(contentPane);
100
101 //Show it.
102 setSize(new Dimension(300, 160));
103 setLocationRelativeTo(frame);
104 setVisible(true);
105
106 } // constructor
107
108 public String
109 getName()
110 {
111 String retval = null;
112 if (nameField != null) {
113 retval = nameField.getText();
114 }
115 return retval;
116 } // getName
117
118 public String
119 getAmnt()
120 {
121 String retval = null;
Search WWH ::




Custom Search