Merge pull request 'Fix 103 (GUI)' (#108) from fix103 into master
flavien's git/Projet_JAVA_P2P_STRI2A/pipeline/head This commit looks good
Details
flavien's git/Projet_JAVA_P2P_STRI2A/pipeline/head This commit looks good
Details
commit
46ea62e684
@ -1,5 +1,5 @@
|
||||
package exception;
|
||||
|
||||
public abstract class LocalException extends Exception {
|
||||
private static final long serialVersionUID = 12L;
|
||||
private static final long serialVersionUID = 13L;
|
||||
}
|
||||
|
@ -0,0 +1,179 @@
|
||||
package gui;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
* @author Louis Royer
|
||||
* @author Flavien Haas
|
||||
* @author JS Auge
|
||||
*@version 1.0
|
||||
*/
|
||||
public class ArgumentsGen extends javax.swing.JPanel {
|
||||
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Creates new form ArgumentsGen
|
||||
*/
|
||||
public ArgumentsGen() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
*/
|
||||
|
||||
@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("7070");
|
||||
jTextField2 = new javax.swing.JTextField("localhost");
|
||||
jTextField3 = new javax.swing.JTextField("localhost");
|
||||
jTextField4 = new javax.swing.JTextField("6969");
|
||||
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:
|
||||
}
|
||||
|
||||
|
||||
/** Actions when click on connect: creat a clientP2Pgui with the infos from textfields*/
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
String hostnameServer = jTextField2.getText();
|
||||
String portServerStr = jTextField1.getText();
|
||||
String hostnameTracker = jTextField3.getText();
|
||||
String portTrackerStr = jTextField4.getText();
|
||||
String protocolClient = jComboBox1.getSelectedItem().toString();
|
||||
System.out.println("hostnameServer: " + hostnameServer);
|
||||
System.out.println("portServer: " + portServerStr);
|
||||
System.out.println("hostnameTracker: " + hostnameTracker);
|
||||
System.out.println("portTracker: " + portTrackerStr);
|
||||
System.out.println("protocol: " + protocolClient);
|
||||
int portServer = Integer.parseInt(portServerStr);
|
||||
int portTracker = Integer.parseInt(portTrackerStr);
|
||||
ClientP2PGUI c = new ClientP2PGUI(hostnameServer, portServer, hostnameTracker, portTracker, protocolClient);
|
||||
c.connect();
|
||||
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
|
||||
topFrame.dispose();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package gui;
|
||||
|
||||
import clientP2P.*;
|
||||
import java.util.List;
|
||||
import clientP2P.ClientManagementUDP;
|
||||
import clientP2P.ClientManagementTCP;
|
||||
import serverP2P.ServerManagementUDP;
|
||||
import clientP2P.ClientInterfaceCLI;
|
||||
import serverP2P.ServerManagementTCP;
|
||||
import tools.Logger;
|
||||
import tools.LogLevel;
|
||||
import tools.Directories;
|
||||
import tools.HostItem;
|
||||
import tools.ServerPortRange;
|
||||
import tools.TrackerPortRange;
|
||||
|
||||
/** Client + Server implementation in GUI
|
||||
* @author Louis Royer
|
||||
* @author Flavien Haas
|
||||
* @author JS Auge
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ClientP2PGUI {
|
||||
private String logDir = "logs/";
|
||||
private String partsDir = ".parts/";
|
||||
private Logger loggerServer;
|
||||
private Logger loggerClient;
|
||||
private Directories directories;
|
||||
private HostItem tracker;
|
||||
private HostItem server;
|
||||
final static boolean DEBUG = false;
|
||||
private String hostnameServer;
|
||||
private String hostnameTracker;
|
||||
private int portServer;
|
||||
private int portTracker;
|
||||
private String protocolP2P;
|
||||
|
||||
/** Initialize loggers if directories and logger are null,
|
||||
* else fail silently.
|
||||
*/
|
||||
public void initDirectoriesAndLoggers() {
|
||||
if (directories == null && loggerServer == null && loggerClient == null) {
|
||||
directories = new Directories("P2P_JAVA_PROJECT_" + server.getPort());
|
||||
directories.createSubdir(logDir);
|
||||
loggerServer = new Logger(directories.getDataHomeDirectory() + logDir + "server.log", DEBUG);
|
||||
loggerClient = new Logger(directories.getDataHomeDirectory() + logDir + "client.log", DEBUG);
|
||||
directories.createSubdir(partsDir);
|
||||
}
|
||||
}
|
||||
|
||||
/** Constructor.
|
||||
* @param hostnameServer hostname to bind
|
||||
* @param portServer port to bind
|
||||
* @param hostnameTracker hostname of tracker
|
||||
* @param portTracker port of tracker
|
||||
* @param protocolP2P protocol used
|
||||
*/
|
||||
public ClientP2PGUI(String hostnameServer, int portServer, String hostnameTracker, int portTracker, String protocolP2P) {
|
||||
|
||||
this.hostnameServer = hostnameServer;
|
||||
this.hostnameTracker = hostnameTracker;
|
||||
this.portServer = portServer;
|
||||
this.portTracker = portTracker;
|
||||
this.protocolP2P = protocolP2P;
|
||||
final ServerPortRange serverPortRange = new ServerPortRange();
|
||||
final TrackerPortRange trackerPortRange = new TrackerPortRange();
|
||||
if (!serverPortRange.isPortInRange(portServer)){
|
||||
ErrorFrame erreur = new ErrorFrame("SERVER: Port not in range. ");
|
||||
}
|
||||
if (!trackerPortRange.isPortInRange(portTracker)){
|
||||
ErrorFrame erreur = new ErrorFrame("TRACKER: Port not in range");
|
||||
}
|
||||
server = new HostItem(hostnameServer, portServer);
|
||||
tracker = new HostItem(hostnameTracker, portTracker);
|
||||
initDirectoriesAndLoggers();
|
||||
System.out.println("Server will listen on port " + portServer + " and serve files from " + directories.getDataHomeDirectory());
|
||||
}
|
||||
|
||||
/**Initiate a connection using fields from ArgumentsGen*/
|
||||
|
||||
public void connect(){
|
||||
System.out.println("using hostname : " + hostnameServer);
|
||||
System.out.println("using port : " + portServer);
|
||||
System.out.println("tracker hostname : " + hostnameTracker);
|
||||
System.out.println("tracker port : " + portTracker);
|
||||
ServerManagementUDP smudp = new ServerManagementUDP(directories.getDataHomeDirectory(), server, tracker, loggerServer);
|
||||
ServerManagementTCP smtcp = new ServerManagementTCP(directories.getDataHomeDirectory(), server, tracker, loggerServer);
|
||||
Thread tudp = new Thread(smudp);
|
||||
tudp.setName("server UDP P2P-JAVA-PROJECT");
|
||||
tudp.start();
|
||||
Thread ttcp = new Thread(smtcp);
|
||||
ttcp.setName("server TCP P2P-JAVA-PROJECT");
|
||||
ttcp.start();
|
||||
|
||||
// Wait a bit before printing client interface
|
||||
// This is not required, but allow to have a cleaner interface
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
Thread tclient;
|
||||
switch (protocolP2P) {
|
||||
case "UDP":
|
||||
case "udp":
|
||||
case "upd": // to avoid users typos
|
||||
case "2" :
|
||||
System.out.println("Starting with UDP");
|
||||
ClientManagementUDP cmudp = new ClientManagementUDP(directories.getDataHomeDirectory(), tracker, directories.getDataHomeDirectory() + partsDir, loggerClient, server);
|
||||
tclient = new Thread(new ClientInterfaceGUI(cmudp, loggerClient, smtcp, smudp));
|
||||
break;
|
||||
case "TCP":
|
||||
case "tcp":
|
||||
case "1":
|
||||
default:
|
||||
System.out.println("Starting with TCP");
|
||||
ClientManagementTCP cmtcp = new ClientManagementTCP(directories.getDataHomeDirectory(), tracker, directories.getDataHomeDirectory() + partsDir, loggerClient, server);
|
||||
tclient = new Thread(new ClientInterfaceGUI(cmtcp, loggerClient, smtcp, smudp));
|
||||
break;
|
||||
}
|
||||
tclient.setName("client P2P-JAVA-PROJECT GUI");
|
||||
tclient.start();
|
||||
try {
|
||||
tclient.join();
|
||||
} catch (InterruptedException e) {}
|
||||
//smudp.setStop();
|
||||
//smtcp.setStop();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
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.
|
||||
*/
|
||||
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import clientP2P.*;
|
||||
import tools.LogLevel;
|
||||
import tools.Logger;
|
||||
import serverP2P.ServerManagementUDP;
|
||||
import serverP2P.ServerManagementTCP;
|
||||
|
||||
/**
|
||||
* @author Louis Royer
|
||||
* @author Flavien Haas
|
||||
* @author JS Auge
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DownloadSelectionGen extends javax.swing.JPanel {
|
||||
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton jButton2;
|
||||
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;
|
||||
private ClientManagement clientManagement;
|
||||
private Logger logger;
|
||||
private ServerManagementTCP smtcp;
|
||||
private ServerManagementUDP smudp;
|
||||
|
||||
|
||||
/**
|
||||
* @param listFilesToDownload list of files to display
|
||||
* @param clientManagement clientManagement
|
||||
* @param logger logger
|
||||
* Creates new form ArgumentsGen
|
||||
*/
|
||||
public DownloadSelectionGen(String[] listFilesToDownload, ClientManagement clientManagement, Logger logger, ServerManagementTCP smtcp, ServerManagementUDP smudp) {
|
||||
this.listFilesToDownload = listFilesToDownload;
|
||||
this.clientManagement = clientManagement;
|
||||
this.logger = logger;
|
||||
this.smtcp = smtcp;
|
||||
this.smudp = smudp;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
*/
|
||||
@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<>();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
|
||||
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);
|
||||
jButton2.setText("Back");
|
||||
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButton2ActionPerformed(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()
|
||||
.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()
|
||||
.addGap(25, 25, 25)
|
||||
.addComponent(jButton2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 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)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jButton1)
|
||||
.addComponent(jButton2))
|
||||
.addContainerGap(24, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>
|
||||
|
||||
|
||||
/** Actions to initiate when button "Download" is pressed */
|
||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
String fileSelected = jList1.getSelectedValue();
|
||||
System.out.println("File to download: " + fileSelected);
|
||||
DownloadFileGUI dl = new DownloadFileGUI(fileSelected, clientManagement, logger, smtcp, smudp);
|
||||
dl.download();
|
||||
}
|
||||
|
||||
/** Actions to initiate when button "Back" is initiate */
|
||||
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
ArgumentsGen a = new ArgumentsGen();
|
||||
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
|
||||
topFrame.add(a);
|
||||
this.setVisible(false);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
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
|
||||
* @version 1.0
|
||||
*/
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* @param message error message that will be displayed
|
||||
* Create new Errorframe, used to display an error and stop the program when needed
|
||||
*/
|
||||
|
||||
public ErrorFrame(String message) {
|
||||
this.message = message;
|
||||
initComponents();
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">
|
||||
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();
|
||||
}// </editor-fold>
|
||||
|
||||
|
||||
/**force exit the program when the button "Close" is pressed*/
|
||||
private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package gui;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
/** Class to download file
|
||||
* @author Louis Royer
|
||||
* @author Flavien Haas
|
||||
* @author JS Auge
|
||||
* @version 1.0
|
||||
* Class used to create the Graphical interface
|
||||
*/
|
||||
|
||||
public class Gui{
|
||||
|
||||
public static void main(String[] args) {
|
||||
MainWindow win = new MainWindow();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package gui;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
/** Class to download file
|
||||
* @author Louis Royer
|
||||
* @author Flavien Haas
|
||||
* @author JS Auge
|
||||
* @version 1.0
|
||||
* Class used to create the main window of the GUI
|
||||
*/
|
||||
|
||||
|
||||
public class MainWindow extends JFrame{
|
||||
|
||||
private static final long serialVersionUID = 13L;
|
||||
|
||||
public MainWindow(){
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setTitle("Client");
|
||||
fenetre.setSize(550, 250);
|
||||
fenetre.setLocationRelativeTo(null);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.add(new ArgumentsGen());
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue