added new panels done with NetBeans

This commit is contained in:
js 2020-04-06 11:03:45 +02:00
parent 4167cc3aa6
commit 3f3e7fd2f3
6 changed files with 289 additions and 11 deletions

View File

@ -1,5 +1,5 @@
package exception; package exception;
public abstract class LocalException extends Exception { public abstract class LocalException extends Exception {
private static final long serialVersionUID = 12L; private static final long serialVersionUID = 13L;
} }

167
src/gui/ArgumentsGen.java Normal file
View File

@ -0,0 +1,167 @@
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 ArgumentsGen extends javax.swing.JPanel {
/**
* Creates new form ArgumentsGen
*/
public ArgumentsGen() {
initComponents();
}
/**
* 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox<>();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel1.setText("Enter connection informations:");
jLabel2.setText("Server hostname:");
jLabel3.setText("Server port:");
jLabel4.setText("Tracker hostname:");
jLabel5.setText("Tracker port:");
jLabel6.setText("Client's protocol:");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "TCP", "UDP" }));
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
jButton1.setText("Connect");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGap(71, 71, 71)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField1)
.addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
.addComponent(jTextField3)
.addComponent(jTextField4)))))
.addContainerGap(138, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(7, 7, 7)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1)
.addContainerGap(16, Short.MAX_VALUE))
);
}// </editor-fold>
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JComboBox<String> 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
}

View File

@ -6,32 +6,41 @@ import javax.swing.JButton;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JScrollPane;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.GridLayout; import java.awt.GridLayout;
public class downloadSelection extends JPanel { public class DownloadSelection extends JPanel {
private static final long serialVersionUID = 13L; private static final long serialVersionUID = 13L;
private String[] listFilesToDownload; private String[] listFilesToDownload;
private JList<String> list1; private JList<String> list1;
private JLabel label1; private JLabel label1;
private JButton downloadButton; private JButton downloadButton;
private JScrollPane scroll;
public downloadSelection(String[] listFilesToDownload){ public DownloadSelection(String[] listFilesToDownload){
JPanel p1 = new JPanel(); JPanel p1 = new JPanel();
JPanel p3 = new JPanel(); JPanel p3 = new JPanel();
JPanel container = new JPanel();
FlowLayout layout = new FlowLayout(); 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.listFilesToDownload = listFilesToDownload;
this.list1 = new JList<>(listFilesToDownload); this.list1 = new JList<>(listFilesToDownload);
this.label1 = new JLabel("List of files you can download: "); this.label1 = new JLabel("List of files you can download: ");
this.downloadButton = new JButton("download"); this.downloadButton = new JButton("download");
this.list1.setSelectedIndex(0); this.list1.setSelectedIndex(0);
p1.setLayout(new GridLayout(1, 2)); scroll = new JScrollPane(list1);
p3.setLayout(layout); int verticalPolicy = JScrollPane.VERTICAL_SCROLLBAR_ALWAYS;
this.setLayout(new GridLayout(2, 1)); scroll.setVerticalScrollBarPolicy(verticalPolicy);
//container.add(list1);
container.add(scroll);
p1.add(label1); p1.add(label1);
p1.add(list1); p1.add(container);
p3.add(downloadButton); p3.add(downloadButton);
this.add(p1); this.add(p1);
this.add(p3); this.add(p3);

View File

@ -0,0 +1,99 @@
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 DownloadSelectionGen extends javax.swing.JPanel {
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JList<String> jList1;
private javax.swing.JScrollPane jScrollPane1;
private static final long serialVersionUID = 13L;
private String[] listFilesToDownload;
// End of variables declaration
/**
* Creates new form ArgumentsGen
*/
public DownloadSelectionGen(String[] listFilesToDownload) {
this.listFilesToDownload = listFilesToDownload;
initComponents();
}
/**
* 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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList<>();
jLabel1.setText("Select a file to download:");
jButton1.setText("Download");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jList1.setModel(new javax.swing.AbstractListModel<String>() {
String[] strings = listFilesToDownload;
public int getSize() { return strings.length; }
public String getElementAt(int i) { return strings[i]; }
});
jScrollPane1.setViewportView(jList1);
jList1.setSelectedIndex(0);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(97, 97, 97)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(104, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(23, 23, 23))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1)
.addContainerGap(24, Short.MAX_VALUE))
);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
}

View File

@ -9,12 +9,15 @@ public class MainWindow extends JFrame{
public MainWindow(){ public MainWindow(){
JFrame fenetre = new JFrame(); JFrame fenetre = new JFrame();
fenetre.setTitle("Client"); fenetre.setTitle("Client");
fenetre.setSize(550, 200); fenetre.setSize(550, 250);
fenetre.setLocationRelativeTo(null); fenetre.setLocationRelativeTo(null);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//fenetre.add(new Parameters()); //fenetre.add(new Parameters());
String[] listTest = {"test", "test2", "test3", "test4", "test5", "test6", "test7"}; //fenetre.add(new ArgumentsGen());
fenetre.add(new downloadSelection(listTest)); String[] listTest = {"test", "test2", "test3", "test4", "test5", "test6", "test7", "fichier1",
"fichier2", "fichier3", "fichier4"};
//fenetre.add(new DownloadSelection(listTest));
fenetre.add(new DownloadSelectionGen(listTest));
fenetre.setVisible(true); fenetre.setVisible(true);
} }

View File

@ -28,7 +28,7 @@ public class Parameters extends JPanel{
this.label2 = new JLabel("Server port: "); this.label2 = new JLabel("Server port: ");
this.label3 = new JLabel("Tracker hostname: "); this.label3 = new JLabel("Tracker hostname: ");
this.label4 = new JLabel("Tracker port: "); this.label4 = new JLabel("Tracker port: ");
this.label5 = new JLabel("Protocol: "); this.label5 = new JLabel("Client's Protocol: ");
this.field1 = new JTextField(20); this.field1 = new JTextField(20);
this.field2 = new JTextField(20); this.field2 = new JTextField(20);
this.field3 = new JTextField(20); this.field3 = new JTextField(20);