first panel of GUI
All checks were successful
flavien's git/Projet_JAVA_P2P_STRI2A/pipeline/head This commit looks good

This commit is contained in:
js 2020-04-03 12:11:29 +02:00
parent 4928efa947
commit 88d4819941
3 changed files with 76 additions and 0 deletions

12
src/gui/Gui.java Normal file
View File

@ -0,0 +1,12 @@
package gui;
import javax.swing.JFrame;
public class Gui{
public static void main(String[] args) {
MainWindow win = new MainWindow();
}
}

17
src/gui/MainWindow.java Normal file
View File

@ -0,0 +1,17 @@
package gui;
import javax.swing.JFrame;
public class MainWindow extends JFrame{
public MainWindow(){
JFrame fenetre = new JFrame();
fenetre.setTitle("Client");
fenetre.setSize(550, 200);
fenetre.setLocationRelativeTo(null);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.add(new Parameters());
fenetre.setVisible(true);
}
}

47
src/gui/Parameters.java Normal file
View File

@ -0,0 +1,47 @@
package gui;
import javax.swing.*;
import java.awt.*;
public class Parameters extends JPanel{
public Parameters(){
JPanel p1 = new JPanel();
p1.setLayout(new GridLayout(5, 2));
FlowLayout layout = new FlowLayout();
JPanel p2 = new JPanel();
p2.setLayout(layout);
Object[] elements = new Object[]{"TCP", "UDP"};
// JSplitPane split;
JLabel label1, label2, label3, label4, label5;
JTextField field1, field2, field3, field4;
JComboBox protocolSelector;
JButton connectButton;
label1 = new JLabel("Server hostname: ");
label2 = new JLabel("Server port: ");
label3 = new JLabel("Tracker hostname: ");
label4 = new JLabel("Tracker port: ");
label5 = new JLabel("Protocol: ");
field1 = new JTextField(20);
field2 = new JTextField(20);
field3 = new JTextField(20);
field4 = new JTextField(20);
protocolSelector = new JComboBox(elements);
connectButton = new JButton("Connect");
p1.add(label1);
p1.add(field1);
p1.add(label2);
p1.add(field2);
p1.add(label3);
p1.add(field3);
p1.add(label4);
p1.add(protocolSelector);
p2.add(connectButton);
//split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, p1, p2);
//this.add(split, BorderLayout.CENTER);
this.add(p1, BorderLayout.NORTH);
this.add(p2, BorderLayout.SOUTH);
setVisible(true);
}
}