URL source;
try {
source = new URL(sourceFile.getText());
} catch (MalformedURLException me) {
JOptionPane.showMessageDialog(this, "Invalid URL.", "Download error", JOptionPane.ERROR_MESSAGE);
return;
}
JFileChooser chooser = new JFileChooser();
chooser.setSelectedFile(new File(new File(source.getFile()).getName()));
chooser.showSaveDialog(this);
File target = chooser.getSelectedFile();
JProgressBar bar;
JPanel panel = new JPanel(new GridLayout(3, 2));
panel.add(new JLabel("Source: "));
panel.add(new JLabel(sourceFile.getText()));
panel.add(new JLabel("Target: "));
panel.add(new JLabel(target.getAbsolutePath()));
panel.add(new JLabel("Progress: "));
panel.add(bar = new JProgressBar());
panel.setBorder(new EmptyBorder(0, 3, 0, 3));
bar.setStringPainted(true);
centerPane.add(Box.createVerticalStrut(3));
centerPane.add(new JSeparator());
centerPane.add(Box.createVerticalStrut(3));
centerPane.add(panel);
centerPane.add(Box.createVerticalStrut(3));
pack();