diff --git a/src/gui/ArgumentsGen.java b/src/gui/ArgumentsGen.java index aefd8c9..1c0f719 100644 --- a/src/gui/ArgumentsGen.java +++ b/src/gui/ArgumentsGen.java @@ -14,6 +14,21 @@ package gui; */ public class ArgumentsGen extends javax.swing.JPanel { + + private javax.swing.JButton jButton1; + private javax.swing.JComboBox jComboBox1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JTextField jTextField1; + private javax.swing.JTextField jTextField2; + private javax.swing.JTextField jTextField3; + private javax.swing.JTextField jTextField4; + private static final long serialVersionUID = 13L; + /** * Creates new form ArgumentsGen */ @@ -145,23 +160,16 @@ public class ArgumentsGen extends javax.swing.JPanel { } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { - // TODO add your handling code here: + String hostnameServer = jTextField2.getText(); + String portServer = jTextField1.getText(); + String hostnameTracker = jTextField3.getText(); + String portTracker = jTextField4.getText(); + String protocolClient = jComboBox1.getSelectedItem().toString(); + System.out.println("hostnameServer: " + hostnameServer); + System.out.println("portServer: " + portServer); + System.out.println("hostnameTracker: " + hostnameTracker); + System.out.println("portTracker: " + portTracker); + System.out.println("protocol: " + protocolClient); } - - // Variables declaration - do not modify - private javax.swing.JButton jButton1; - private javax.swing.JComboBox jComboBox1; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JTextField jTextField1; - private javax.swing.JTextField jTextField2; - private javax.swing.JTextField jTextField3; - private javax.swing.JTextField jTextField4; - private static final long serialVersionUID = 13L; - // End of variables declaration } diff --git a/src/gui/DownloadSelection.java b/src/gui/DownloadSelection.java deleted file mode 100644 index 213eae5..0000000 --- a/src/gui/DownloadSelection.java +++ /dev/null @@ -1,50 +0,0 @@ -package gui; - -import javax.swing.JPanel; -import javax.swing.JLabel; -import javax.swing.JButton; -import javax.swing.JTextField; -import javax.swing.JComboBox; -import javax.swing.JList; -import javax.swing.JScrollPane; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridLayout; - -public class DownloadSelection extends JPanel { - - private static final long serialVersionUID = 13L; - private String[] listFilesToDownload; - private JList list1; - private JLabel label1; - private JButton downloadButton; - private JScrollPane scroll; - - public DownloadSelection(String[] listFilesToDownload){ - JPanel p1 = new JPanel(); - JPanel p3 = new JPanel(); - JPanel container = new JPanel(); - FlowLayout layout = new FlowLayout(); - p1.setLayout(new GridLayout(1, 2)); - container.setLayout(layout); - p3.setLayout(layout); - this.setLayout(new GridLayout(2, 1)); - this.listFilesToDownload = listFilesToDownload; - this.list1 = new JList<>(listFilesToDownload); - this.label1 = new JLabel("List of files you can download: "); - this.downloadButton = new JButton("download"); - this.list1.setSelectedIndex(0); - scroll = new JScrollPane(list1); - int verticalPolicy = JScrollPane.VERTICAL_SCROLLBAR_ALWAYS; - scroll.setVerticalScrollBarPolicy(verticalPolicy); - //container.add(list1); - container.add(scroll); - p1.add(label1); - p1.add(container); - p3.add(downloadButton); - this.add(p1); - this.add(p3); - setVisible(true); - } - -} diff --git a/src/gui/ErrorFrame.java b/src/gui/ErrorFrame.java new file mode 100644 index 0000000..4f23ce2 --- /dev/null +++ b/src/gui/ErrorFrame.java @@ -0,0 +1,87 @@ +package gui; + + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + + /** + * @author Louis Royer + * @author Flavien Haas + * @author JS Auge + */ +public class ErrorFrame extends javax.swing.JFrame { + + private javax.swing.JLabel jLabel1; + private javax.swing.JToggleButton jToggleButton1; + private String message; + private static final long serialVersionUID = 13L; + // End of variables declaration + + + public ErrorFrame(String message) { + this.message = message; + initComponents(); + this.setVisible(true); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // + private void initComponents() { + + jToggleButton1 = new javax.swing.JToggleButton(); + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jToggleButton1.setText("Close"); + jToggleButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jToggleButton1ActionPerformed(evt); + } + }); + + jLabel1.setText(message); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1)) + .addGroup(layout.createSequentialGroup() + .addGap(253, 253, 253) + .addComponent(jToggleButton1))) + .addContainerGap(205, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addGap(30, 30, 30) + .addComponent(jToggleButton1) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + this.setLocationRelativeTo(null); + this.setAlwaysOnTop(true); + pack(); + }// + + private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) { + System.exit(1); + } + + +} diff --git a/src/gui/MainWindow.java b/src/gui/MainWindow.java index ae8b931..d7ac1d4 100644 --- a/src/gui/MainWindow.java +++ b/src/gui/MainWindow.java @@ -19,6 +19,7 @@ public class MainWindow extends JFrame{ //fenetre.add(new DownloadSelection(listTest)); fenetre.add(new DownloadSelectionGen(listTest)); fenetre.setVisible(true); + ErrorFrame erreur = new ErrorFrame("ceci est une erreur"); } } diff --git a/src/gui/Parameters.java b/src/gui/Parameters.java deleted file mode 100644 index a715d1c..0000000 --- a/src/gui/Parameters.java +++ /dev/null @@ -1,54 +0,0 @@ -package gui; - -import javax.swing.JPanel; -import javax.swing.JLabel; -import javax.swing.JButton; -import javax.swing.JTextField; -import javax.swing.JComboBox; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.GridLayout; - -public class Parameters extends JPanel{ - - private static final long serialVersionUID = 13L; - private JLabel label1, label2, label3, label4, label5; - private JTextField field1, field2, field3, field4; - private JButton connectButton; - private JComboBox protocolSelector; - - public Parameters(){ - JPanel p1 = new JPanel(); - p1.setLayout(new GridLayout(5, 2)); - FlowLayout layout = new FlowLayout(); - JPanel p2 = new JPanel(); - p2.setLayout(layout); - String[] elements = {"TCP", "UDP"}; - this.label1 = new JLabel("Server hostname: "); - this.label2 = new JLabel("Server port: "); - this.label3 = new JLabel("Tracker hostname: "); - this.label4 = new JLabel("Tracker port: "); - this.label5 = new JLabel("Client's Protocol: "); - this.field1 = new JTextField(20); - this.field2 = new JTextField(20); - this.field3 = new JTextField(20); - this.field4 = new JTextField(20); - this.connectButton = new JButton("Connect"); - protocolSelector = new JComboBox<>(elements); - p1.add(label1); - p1.add(field1); - p1.add(label2); - p1.add(field2); - p1.add(label3); - p1.add(field3); - p1.add(label4); - p1.add(field4); - p1.add(label5); - p1.add(protocolSelector); - p2.add(connectButton); - this.add(p1, BorderLayout.NORTH); - this.add(p2, BorderLayout.SOUTH); - setVisible(true); - } - -}