Phase jsp
This commit is contained in:
parent
0a250955b2
commit
1e9789684f
3 changed files with 45 additions and 10 deletions
|
|
@ -41,7 +41,7 @@ public class Controle implements AsyncResponse {
|
|||
//
|
||||
new ServeurSocket(this, GLOBAL.PORT);
|
||||
|
||||
this.frmArene = new Arene();
|
||||
this.frmArene = new Arene(this);
|
||||
this.frmArene.setVisible(true);
|
||||
|
||||
this.leJeu = new JeuServeur(this);
|
||||
|
|
@ -65,7 +65,7 @@ public class Controle implements AsyncResponse {
|
|||
this.leJeu = new JeuClient(this);
|
||||
this.leJeu.connexion(connection);
|
||||
|
||||
this.frmArene = new Arene();
|
||||
this.frmArene = new Arene(this);
|
||||
this.frmChoixJoueur = new ChoixJoueur(this);
|
||||
this.frmChoixJoueur.setVisible(true);
|
||||
}else {
|
||||
|
|
@ -117,4 +117,12 @@ public class Controle implements AsyncResponse {
|
|||
}
|
||||
}
|
||||
|
||||
public void evenementArene(String ordre, Object info) {
|
||||
switch(ordre) {
|
||||
case "tchat":
|
||||
((JeuClient)this.leJeu).envoi("tchat" + GLOBAL.separateur + info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,6 +172,10 @@ public class Joueur extends Objet {
|
|||
return false;
|
||||
}
|
||||
|
||||
public String getSpeudo() {
|
||||
return this.pseudo;
|
||||
}
|
||||
|
||||
/**
|
||||
* vrai si la vie est à 0
|
||||
* @return true si vie = 0
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import javax.swing.JFrame;
|
|||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import controleur.Controle;
|
||||
import controleur.GLOBAL;
|
||||
import modele.Mur;
|
||||
|
||||
|
|
@ -19,14 +20,18 @@ import javax.swing.JTextField;
|
|||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class Arene extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JPanel contentPane;
|
||||
private JTextField textField;
|
||||
private JTextField txtSaisie;
|
||||
private JPanel jpnMur;
|
||||
public JPanel jpnJeu;
|
||||
public JTextArea txtChat;
|
||||
private Controle controle;
|
||||
|
||||
/**
|
||||
* Launch the application.
|
||||
|
|
@ -35,7 +40,7 @@ public class Arene extends JFrame {
|
|||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public Arene() {
|
||||
public Arene(Controle controle) {
|
||||
setTitle("Arene");
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.getContentPane().setPreferredSize(new Dimension(800, 729));
|
||||
|
|
@ -77,18 +82,27 @@ public class Arene extends JFrame {
|
|||
lblNewLabel.setBounds(0, 0, 792, 590);
|
||||
contentPane.add(lblNewLabel);
|
||||
|
||||
textField = new JTextField();
|
||||
textField.setBounds(0, 591, 800, 30);
|
||||
contentPane.add(textField);
|
||||
textField.setColumns(10);
|
||||
txtSaisie = new JTextField();
|
||||
txtSaisie.setBounds(0, 591, 800, 30);
|
||||
contentPane.add(txtSaisie);
|
||||
txtSaisie.setColumns(10);
|
||||
|
||||
txtSaisie.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if(!Arene.this.txtSaisie.equals("") && e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
controle.evenementArene("tchat", Arene.this.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setBounds(0, 620, 800, 98);
|
||||
contentPane.add(scrollPane);
|
||||
|
||||
JTextArea textArea = new JTextArea();
|
||||
scrollPane.setViewportView(textArea);
|
||||
txtChat = new JTextArea();
|
||||
scrollPane.setViewportView(txtChat);
|
||||
}
|
||||
public void ajoutMurs(Object portougal) {
|
||||
jpnMur.add((JLabel)portougal);
|
||||
|
|
@ -117,4 +131,13 @@ public class Arene extends JFrame {
|
|||
this.jpnJeu.add(jpnJeu);
|
||||
this.jpnJeu.repaint();
|
||||
}
|
||||
public String getMessage() {
|
||||
return this.txtSaisie.getText();
|
||||
}
|
||||
public void setMessage(String msg) {
|
||||
this.txtChat.setText(msg);
|
||||
}
|
||||
public void ajoutTchat(String Staline) {
|
||||
this.txtChat.setText(this.txtChat.getText() + Staline + "\r\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue