Merge branch 'master' of https://git.etud.insa-toulouse.fr/gallois/Clavardage
This commit is contained in:
commit
a58cd8294c
1 changed files with 25 additions and 16 deletions
|
@ -4,7 +4,10 @@ import javax.swing.*;
|
|||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import controller.Controller;
|
||||
import model.RemoteUser;
|
||||
|
||||
public class Interface implements ActionListener {
|
||||
|
||||
|
@ -17,7 +20,7 @@ public class Interface implements ActionListener {
|
|||
public JTextField MessagetextField;
|
||||
|
||||
public JButton RemoteUserButton;
|
||||
public JLabel RemoteUserlabel;
|
||||
public JComboBox RemoteUserbox;
|
||||
|
||||
//Specifies the look and feel to use. Valid values:
|
||||
//null (use the default), "Metal", "System", "Motif", "GTK+"
|
||||
|
@ -34,6 +37,18 @@ public class Interface implements ActionListener {
|
|||
Pseudolabel = new JLabel("Your current username is: " + hisController.getMyUser().getPseudo());
|
||||
Pseudolabel.setLabelFor(PseudotextField);
|
||||
|
||||
RemoteUserButton = new JButton("Click here to get Remote User list"); //Remote user list setup
|
||||
RemoteUserButton.addActionListener(this);
|
||||
//Convert the Userlist to Pseudotab
|
||||
String[] pseudotab = new String[hisController.getMyUser().getRemoteUsersList().size()];
|
||||
for(int i=0; i < hisController.getMyUser().getRemoteUsersList().size(); i++) {
|
||||
pseudotab[i] = "(" + Integer.toString(i) + "): " + hisController.getMyUser().getRemoteUsersList().get(i).getPseudo();
|
||||
}
|
||||
RemoteUserbox = new JComboBox(pseudotab);
|
||||
RemoteUserbox.setEditable(true);
|
||||
RemoteUserbox.addActionListener(this);
|
||||
RemoteUserbox.setVisible(false);
|
||||
|
||||
MessagetextField = new JTextField(); //Messages setup
|
||||
MessagetextField.setColumns(10);
|
||||
MessagetextField.addActionListener(this);
|
||||
|
@ -41,12 +56,6 @@ public class Interface implements ActionListener {
|
|||
Messagelabel.setLabelFor(MessagetextField);
|
||||
MessagetextField.setVisible(false);
|
||||
Messagelabel.setVisible(false);
|
||||
|
||||
RemoteUserButton = new JButton("Click here to get Remote User list"); //Remote user list setup
|
||||
RemoteUserButton.addActionListener(this);
|
||||
RemoteUserlabel = new JLabel("Remote User List:");
|
||||
RemoteUserlabel.setLabelFor(RemoteUserButton);
|
||||
RemoteUserlabel.setVisible(false);
|
||||
|
||||
/*
|
||||
* An easy way to put space between a top-level container
|
||||
|
@ -56,10 +65,10 @@ public class Interface implements ActionListener {
|
|||
JPanel pane = new JPanel(new GridLayout(0, 2));
|
||||
pane.add(Pseudolabel);
|
||||
pane.add(PseudotextField);
|
||||
pane.add(RemoteUserButton);
|
||||
pane.add(RemoteUserbox);
|
||||
pane.add(Messagelabel);
|
||||
pane.add(MessagetextField);
|
||||
pane.add(RemoteUserButton);
|
||||
pane.add(RemoteUserlabel);
|
||||
pane.setBorder(BorderFactory.createEmptyBorder(
|
||||
30, //top
|
||||
30, //left
|
||||
|
@ -79,7 +88,7 @@ public class Interface implements ActionListener {
|
|||
try {
|
||||
hisController.changePseudo();
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println("Error in change pseudo\n");
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}else if(e.getSource() == MessagetextField){ //Messages
|
||||
|
@ -88,14 +97,14 @@ public class Interface implements ActionListener {
|
|||
//TODO mettre Textinput dans la database
|
||||
MessagetextField.setText("");
|
||||
}else if(e.getSource() == RemoteUserButton) { //Shows remote user list
|
||||
showRemoteUserList();
|
||||
RemoteUserbox.setVisible(true);
|
||||
}else {
|
||||
JComboBox cb = (JComboBox)e.getSource(); //Casts obscurs pour récupérer le numéro du user dans la liste
|
||||
int selectedUsernb = Integer.parseInt(String.valueOf(((String) cb.getSelectedItem()).charAt(1)));
|
||||
System.out.println("selectedUsernb: " + selectedUsernb); //Test pour voir si ça marche
|
||||
//TODO Utiliser ce selectedUsernb pour faire le lien avec openSession de Controller
|
||||
}
|
||||
}
|
||||
|
||||
public void showRemoteUserList() {
|
||||
RemoteUserlabel.setVisible(true);
|
||||
RemoteUserlabel.setText("Remote users");
|
||||
}
|
||||
|
||||
private static void initLookAndFeel() {
|
||||
// Swing allows you to specify which look and feel your program uses-
|
||||
|
|
Loading…
Reference in a new issue