|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
package gui;
|
|
|
|
|
|
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
|
import javax.swing.SwingUtilities;
|
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
|
import javax.swing.SwingUtilities;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Louis Royer
|
|
|
|
@ -12,152 +12,152 @@ package gui;
|
|
|
|
|
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 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("7071");
|
|
|
|
|
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:
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 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) {
|
|
|
|
|
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
|
|
String hostnameServer = jTextField2.getText();
|
|
|
|
|
String portServerStr = jTextField1.getText();
|
|
|
|
|
String hostnameTracker = jTextField3.getText();
|
|
|
|
@ -174,6 +174,6 @@ public class ArgumentsGen extends javax.swing.JPanel {
|
|
|
|
|
c.connect();
|
|
|
|
|
JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
|
|
|
|
|
topFrame.dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|