batchLabel.setPreferredSize(
new Dimension(160, batchLabel.getPreferredSize().height)
);
batchLabel.setMaximumSize(batchLabel.getPreferredSize());
ExportMultiControls exportCtrls =
new ExportMultiControls(config.export, dialog, false);
JButton start = new JButton(LOCALE.get("BatchConfStartButton"));
start.setAlignmentX(.5f);
JButton cancel = new JButton(LOCALE.get("BatchConfCancelButton"));
cancel.setAlignmentX(.5f);
started = false;
ActionListener disposeAction = new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.setVisible(false);
}
};
start.addActionListener(disposeAction);
cancel.addActionListener(disposeAction);
start.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
started = true;
}
}
);
// Define layout:
Box buttons = Box.createHorizontalBox();
buttons.add(Box.createHorizontalGlue());
buttons.add(start);
buttons.add(Box.createHorizontalStrut(8));
buttons.add(cancel);
buttons.setMaximumSize(buttons.getPreferredSize());
JPanel batchLabelBox = new JPanel();
batchLabelBox.setLayout(new BoxLayout(batchLabelBox, BoxLayout.X_AXIS));
batchLabelBox.add(batchLabel);
batchLabelBox.setBorder(
BorderFactory.createTitledBorder(
LOCALE.get("BatchConfNameLabel")
)
);
Box batchBox = Box.createHorizontalBox();
batchBox.add(batchLabelBox);
batchBox.add(Box.createHorizontalGlue());
JPanel dirBox = new JPanel();
dirBox.setLayout(new BoxLayout(dirBox, BoxLayout.X_AXIS));
if (isBatchExport) {
dirBox.add(new JLabel(LOCALE.get("BatchConfExportOutputLabel")));
}
else {
dirBox.add(new JLabel(LOCALE.get("BatchConfSaveOutputLabel")));
}
dirBox.add(Box.createHorizontalStrut(8));
dirBox.add(dirLabel);
dirBox.add(Box.createHorizontalStrut(8));
dirBox.add(dirButton);
Box dirBoxBox = Box.createHorizontalBox();
dirBoxBox.add(dirBox);
dirBoxBox.add(Box.createHorizontalGlue());
exportCtrls.setBorder(
BorderFactory.createTitledBorder(
LOCALE.get("BatchConfFormatBorder")
)
);
JPanel content = new JPanel();
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
content.add(dirBoxBox);
content.add(Box.createVerticalStrut(8));
content.add(batchBox);
content.add(Box.createVerticalStrut(8));
content.add(exportCtrls);
content.add(Box.createVerticalStrut(8));
content.add(buttons);
content.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
// Hook up the escape key:
content.registerKeyboardAction(
disposeAction,
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW
);
// Set up the dialog:
dialog.setContentPane(content);
dialog.getRootPane().setDefaultButton(start);
dialog.setModal(true);
dialog.setTitle(LOCALE.get("BatchConfDialogTitle"));
dialog.pack();
dialog.setResizable(false);
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
if (started) {
config.export =
(ImageFileExportOptions) exportCtrls.getSelectedExportOptions();
// Remember choices for next time:
config.saveToPrefs(saveKey);
return config;
}
else {