From 4294c84358d487624060cc1ef7edfd439871c717 Mon Sep 17 00:00:00 2001 From: tspitzer Date: Wed, 4 Sep 2013 15:31:41 +0200 Subject: neue features - Erstes Wizard Fenster mit Rohlingsauswahl - Erste Version des Downloaders ohne Progressbar --- Dozentenmodul/src/GUI/Downloader.java | 117 ++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 Dozentenmodul/src/GUI/Downloader.java (limited to 'Dozentenmodul/src/GUI/Downloader.java') diff --git a/Dozentenmodul/src/GUI/Downloader.java b/Dozentenmodul/src/GUI/Downloader.java new file mode 100644 index 00000000..8a44c38b --- /dev/null +++ b/Dozentenmodul/src/GUI/Downloader.java @@ -0,0 +1,117 @@ +package GUI; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.border.EmptyBorder; +import java.awt.Color; +import javax.swing.SwingConstants; +import javax.swing.JLabel; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import javax.swing.JProgressBar; + +import ftp.ftp; + +public class Downloader extends JDialog { + + private final JPanel contentPanel = new JPanel(); + JLabel lblNewLabel; + JProgressBar progressBar; + ftp f=new ftp(); + /** + * Launch the application. + */ + public static void main(String[] args) { + try { + Downloader dialog = new Downloader(); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Create the dialog. + */ + public Downloader() { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + setBackground(Color.WHITE); + setTitle("Downloader"); + setBounds(100, 100, 450, 218); + getContentPane().setLayout(new BorderLayout()); + contentPanel.setBackground(Color.WHITE); + contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + getContentPane().add(contentPanel, BorderLayout.CENTER); + contentPanel.setLayout(null); + { + JButton btnSpeicherortAuswhlen = new JButton("Speicherort ausw\u00E4hlen"); + btnSpeicherortAuswhlen.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + JFileChooser fc=new JFileChooser(); + fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + + fc.showOpenDialog(getParent()); + File dir=fc.getSelectedFile(); + lblNewLabel.setText(dir.getAbsolutePath()); + } + }); + btnSpeicherortAuswhlen.setBounds(10, 11, 141, 23); + btnSpeicherortAuswhlen.setVerticalAlignment(SwingConstants.TOP); + btnSpeicherortAuswhlen.setHorizontalAlignment(SwingConstants.LEFT); + contentPanel.add(btnSpeicherortAuswhlen); + } + + lblNewLabel = new JLabel("C:\\"); + lblNewLabel.setBounds(169, 11, 255, 23); + contentPanel.add(lblNewLabel); + + JButton btnDownloadStarten = new JButton("Download starten"); + btnDownloadStarten.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + progressBar.setValue(0); + long fsize=f.getFileSize("BESCHREIBUNG.xml"); + f.getFile("BESCHREIBUNG.xml", lblNewLabel.getText().toString()); + } + }); + btnDownloadStarten.setBounds(10, 106, 141, 23); + contentPanel.add(btnDownloadStarten); + + progressBar = new JProgressBar(0,100); + progressBar.setBounds(10, 45, 414, 30); + contentPanel.add(progressBar); + { + JPanel buttonPane = new JPanel(); + buttonPane.setBackground(Color.WHITE); + buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); + getContentPane().add(buttonPane, BorderLayout.SOUTH); + { + JButton okButton = new JButton("OK"); + okButton.setActionCommand("OK"); + buttonPane.add(okButton); + getRootPane().setDefaultButton(okButton); + } + { + JButton cancelButton = new JButton("Zur\u00FCck"); + cancelButton.setActionCommand("Cancel"); + buttonPane.add(cancelButton); + } + } + } +} -- cgit v1.2.3-55-g7522