getting the informations for connect with textfield by clicking on connect

This commit is contained in:
js 2020-04-09 09:32:40 +02:00
parent 69bfbb00d4
commit b5c07299d2
5 changed files with 113 additions and 121 deletions

View File

@ -14,6 +14,21 @@ package gui;
*/ */
public class ArgumentsGen extends javax.swing.JPanel { 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 * Creates new form ArgumentsGen
*/ */
@ -145,23 +160,16 @@ public class ArgumentsGen extends javax.swing.JPanel {
} }
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { 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<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

@ -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<String> 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);
}
}

87
src/gui/ErrorFrame.java Normal file
View File

@ -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")
// <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>
private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(1);
}
}

View File

@ -19,6 +19,7 @@ public class MainWindow extends JFrame{
//fenetre.add(new DownloadSelection(listTest)); //fenetre.add(new DownloadSelection(listTest));
fenetre.add(new DownloadSelectionGen(listTest)); fenetre.add(new DownloadSelectionGen(listTest));
fenetre.setVisible(true); fenetre.setVisible(true);
ErrorFrame erreur = new ErrorFrame("ceci est une erreur");
} }
} }

View File

@ -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<String> 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);
}
}