13 |
|
|
14 |
import javax.swing.AbstractAction; |
import javax.swing.AbstractAction; |
15 |
import javax.swing.Action; |
import javax.swing.Action; |
16 |
|
import javax.swing.BorderFactory; |
17 |
import javax.swing.Box; |
import javax.swing.Box; |
18 |
|
import javax.swing.JButton; |
19 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
20 |
import javax.swing.JDialog; |
import javax.swing.JDialog; |
21 |
import javax.swing.JOptionPane; |
import javax.swing.JOptionPane; |
51 |
|
|
52 |
private boolean hasBeenCanceled; |
private boolean hasBeenCanceled; |
53 |
|
|
54 |
|
private JButton[] optionalButtons; |
55 |
|
|
56 |
/** |
/** |
57 |
* Since the registerKeyboardAction() method is part of the JComponent class |
* Since the registerKeyboardAction() method is part of the JComponent class |
58 |
* definition, you must define the Escape keystroke and register the |
* definition, you must define the Escape keystroke and register the |
156 |
SwingUtil.centerFrameOnScreen(this); |
SwingUtil.centerFrameOnScreen(this); |
157 |
Box box = Box.createVerticalBox(); |
Box box = Box.createVerticalBox(); |
158 |
for (JComponent panel : translationEditJPanelsOrJustComponents) { |
for (JComponent panel : translationEditJPanelsOrJustComponents) { |
159 |
|
panel.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT); |
160 |
|
panel.setBorder( BorderFactory.createEmptyBorder(5, 6, 5, 6)); |
161 |
box.add(panel); |
box.add(panel); |
162 |
|
|
163 |
} |
} |
164 |
JPanel cp = new JPanel(new BorderLayout()); |
JPanel cp = new JPanel(new BorderLayout()); |
165 |
cp.add(box, BorderLayout.CENTER); |
cp.add(box, BorderLayout.WEST); |
166 |
cp.add(getButtons(), BorderLayout.SOUTH); |
cp.add(getButtons(), BorderLayout.SOUTH); |
167 |
setContentPane(cp); |
setContentPane(cp); |
168 |
|
|
169 |
setTitle(RESOURCE.getString("translation_dialog_title")); // i8n |
setTitle(RESOURCE.getString("translation_dialog_title")); // i8n |
170 |
setModal(true); |
setModal(true); |
171 |
pack(); |
pack(); |
172 |
} |
} |
173 |
|
|
174 |
|
public void setButtons(JButton... optionalButtons) { |
175 |
|
this.optionalButtons = optionalButtons; |
176 |
|
init(); |
177 |
|
} |
178 |
|
|
179 |
protected void cancel() { |
protected void cancel() { |
180 |
firePropertyChange(PROPERTY_CANCEL_AND_CLOSE, null, null); |
firePropertyChange(PROPERTY_CANCEL_AND_CLOSE, null, null); |
181 |
restore(); |
restore(); |
195 |
|
|
196 |
private JComponent getButtons() { |
private JComponent getButtons() { |
197 |
JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
198 |
|
|
199 |
|
if (optionalButtons != null) |
200 |
|
for (JButton b : optionalButtons) { |
201 |
|
jPanel.add(b); |
202 |
|
} |
203 |
|
|
204 |
if (okButton == null) { |
if (okButton == null) { |
205 |
okButton = new OkButton(new AbstractAction() { |
okButton = new OkButton(new AbstractAction() { |
206 |
{ |
{ |