14 |
import javax.swing.AbstractAction; |
import javax.swing.AbstractAction; |
15 |
import javax.swing.Action; |
import javax.swing.Action; |
16 |
import javax.swing.Box; |
import javax.swing.Box; |
17 |
|
import javax.swing.JButton; |
18 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
19 |
import javax.swing.JDialog; |
import javax.swing.JDialog; |
20 |
import javax.swing.JOptionPane; |
import javax.swing.JOptionPane; |
50 |
|
|
51 |
private boolean hasBeenCanceled; |
private boolean hasBeenCanceled; |
52 |
|
|
53 |
|
private JButton[] optionalButtons; |
54 |
|
|
55 |
/** |
/** |
56 |
* Since the registerKeyboardAction() method is part of the JComponent class |
* Since the registerKeyboardAction() method is part of the JComponent class |
57 |
* definition, you must define the Escape keystroke and register the |
* definition, you must define the Escape keystroke and register the |
167 |
pack(); |
pack(); |
168 |
} |
} |
169 |
|
|
170 |
|
public void setButtons(JButton... optionalButtons) { |
171 |
|
this.optionalButtons = optionalButtons; |
172 |
|
init(); |
173 |
|
} |
174 |
|
|
175 |
protected void cancel() { |
protected void cancel() { |
176 |
firePropertyChange(PROPERTY_CANCEL_AND_CLOSE, null, null); |
firePropertyChange(PROPERTY_CANCEL_AND_CLOSE, null, null); |
177 |
restore(); |
restore(); |
191 |
|
|
192 |
private JComponent getButtons() { |
private JComponent getButtons() { |
193 |
JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
194 |
|
|
195 |
|
if (optionalButtons != null) |
196 |
|
for (JButton b : optionalButtons) { |
197 |
|
jPanel.add(b); |
198 |
|
} |
199 |
|
|
200 |
if (okButton == null) { |
if (okButton == null) { |
201 |
okButton = new OkButton(new AbstractAction() { |
okButton = new OkButton(new AbstractAction() { |
202 |
{ |
{ |