public JProgressWindow(final Component parent) {
/*
* Creates the window containing the components.
*/
Dimension parentSize;
final Vocabulary resources = Vocabulary.getResources(parent!=null ? parent.getLocale() : null);
final String title = resources.getString(VocabularyKeys.PROGRESSION);
final JDesktopPane desktop = JOptionPane.getDesktopPaneForComponent(parent);
if (desktop != null) {
final JInternalFrame frame;
frame = new JInternalFrame(title);
window = frame;
content = new JPanel(); // Pour avoir un fond opaque
parentSize = desktop.getSize();
frame.setContentPane(content);
frame.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
desktop.add(frame, JLayeredPane.PALETTE_LAYER);
} else {
final JDialog dialog;
dialog = new JDialog((Frame)null, title);
window = dialog;
content = (JComponent) dialog.getContentPane();
parentSize = Toolkit.getDefaultToolkit().getScreenSize();
dialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
dialog.setResizable(false);
}
window.setBounds((parentSize.width-WIDTH)/2, (parentSize.height-HEIGHT)/2, WIDTH, HEIGHT);
/*
* Creates the label that is going to display the undergoing operation.
* This label is initially empty.
*/
description = new JLabel();
description.setHorizontalAlignment(JLabel.CENTER);
/*
* Creates the progress bar.
*/
progressBar = new JProgressBar();
progressBar.setIndeterminate(true);
progressBar.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(6,9,6,9),
progressBar.getBorder()));
/*
* Creates the cancel button.
*/
cancel = new JButton(resources.getString(VocabularyKeys.CANCEL));
cancel.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent e ) {
setCanceled( true );
}
});