Corrections de bugs
This commit is contained in:
parent
5be454e081
commit
48594fc3e1
20 changed files with 70 additions and 23 deletions
|
@ -16,7 +16,7 @@
|
|||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="C:/Users/momof/eclipse-workspace/chatGitElise/lib/JTattoo-1.6.13.jar">
|
||||
<classpathentry kind="lib" path="lib/JTattoo-1.6.13.jar">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
|
|
BIN
chatGitElise/b1.jpg
Normal file
BIN
chatGitElise/b1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
chatGitElise/bin/gui/FenetreChat$3.class
Normal file
BIN
chatGitElise/bin/gui/FenetreChat$3.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
chatGitElise/bin/gui/FenetreInscription$3.class
Normal file
BIN
chatGitElise/bin/gui/FenetreInscription$3.class
Normal file
Binary file not shown.
BIN
chatGitElise/bin/gui/FenetreInscription$4.class
Normal file
BIN
chatGitElise/bin/gui/FenetreInscription$4.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -163,12 +163,10 @@ public class Agent implements PropertyChangeListener{
|
|||
FenetreMenu.getCb().removeItem(messageDeconnexion.getPseudo());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//fermeture de la fenetre chat le user et la personne qui se deconnecte
|
||||
if(FenetreChat.isOuvert()&&FenetreChat.getDest().getPseudo().equals(messageDeconnexion.getPseudo())) {
|
||||
FenetreChat.fermer();
|
||||
//getTCPChat().getSocket().close();
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -360,6 +358,10 @@ public class Agent implements PropertyChangeListener{
|
|||
return listTCPDeg;
|
||||
}
|
||||
|
||||
public ArrayList<TCPChat> getListeTCPChat2(){
|
||||
return listTCPOk;
|
||||
}
|
||||
|
||||
public TCPChat getTCPChat() {
|
||||
return this.listTCPDeg.remove(0);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package gui;
|
|||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
@ -17,6 +19,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.DefaultCaret;
|
||||
import javax.swing.text.SimpleAttributeSet;
|
||||
|
@ -24,6 +27,7 @@ import javax.swing.text.StyleConstants;
|
|||
import javax.swing.text.StyledDocument;
|
||||
|
||||
import controller.Agent;
|
||||
import controller.DataBase;
|
||||
import model.Contact;
|
||||
import model.MessageAffichage;
|
||||
import network.TCPChat;
|
||||
|
@ -33,6 +37,18 @@ import java.awt.*;
|
|||
|
||||
public class FenetreChat extends JFrame implements PropertyChangeListener{
|
||||
|
||||
private static FenetreChat instance = null;
|
||||
|
||||
public static FenetreChat getInstance(Agent agent, String userString) throws IOException {
|
||||
synchronized (FenetreChat.class) {
|
||||
FenetreChat fc = instance;
|
||||
if(fc == null) {
|
||||
fc = new FenetreChat(agent, userString);
|
||||
}
|
||||
return fc;
|
||||
}
|
||||
}
|
||||
|
||||
static JFrame frame;
|
||||
static Agent agent;
|
||||
static Contact dest; //destinataire du message
|
||||
|
@ -41,6 +57,7 @@ public class FenetreChat extends JFrame implements PropertyChangeListener{
|
|||
WindowAdapter wa;
|
||||
JPanel panel;
|
||||
static JTextArea text;
|
||||
JButton envoyer;
|
||||
|
||||
private TCPChat t=null;
|
||||
|
||||
|
@ -48,7 +65,7 @@ public class FenetreChat extends JFrame implements PropertyChangeListener{
|
|||
private static boolean ouvert=false;
|
||||
|
||||
|
||||
public FenetreChat(Agent agent, String userString) throws IOException {
|
||||
private FenetreChat(Agent agent, String userString) throws IOException {
|
||||
FenetreChat.ouvert=true;
|
||||
|
||||
this.frame = new JFrame("Fenetre Chat avec "+ userString);
|
||||
|
@ -90,7 +107,7 @@ public class FenetreChat extends JFrame implements PropertyChangeListener{
|
|||
this.addWidgets();
|
||||
//frame.getContentPane().add(panel, BorderLayout.CENTER);
|
||||
afficherHistorique();
|
||||
|
||||
frame.getRootPane().setDefaultButton(envoyer);
|
||||
|
||||
frame.addWindowListener(wa);
|
||||
frame.setVisible(true);
|
||||
|
@ -126,10 +143,32 @@ public class FenetreChat extends JFrame implements PropertyChangeListener{
|
|||
//zone pour rentrer les message à envoyer
|
||||
text = new JTextArea(10, 3);
|
||||
text.setForeground(Color.WHITE);
|
||||
text.setFont(new Font("Century Schoolbook", Font.PLAIN, 11));
|
||||
text.setBackground(Color.GRAY);
|
||||
text.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
|
||||
text.setFont(new Font("Century Schoolbook", Font.PLAIN, 12));
|
||||
text.setText("Enter your message");
|
||||
text.setOpaque(false);
|
||||
|
||||
text.addKeyListener(new KeyListener() {
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER){
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
JScrollPane sp = new JScrollPane(text);
|
||||
|
||||
//zone affichage texte
|
||||
|
@ -143,7 +182,7 @@ public class FenetreChat extends JFrame implements PropertyChangeListener{
|
|||
frame.getContentPane().add(sp2, gbc);
|
||||
|
||||
//bouton envoyer
|
||||
JButton envoyer = new JButton("Send");
|
||||
envoyer = new JButton("Send");
|
||||
envoyer.setOpaque(false);
|
||||
frame.getRootPane().setDefaultButton(envoyer);
|
||||
envoyer.addActionListener(new ActionListener() {
|
||||
|
@ -279,6 +318,7 @@ public class FenetreChat extends JFrame implements PropertyChangeListener{
|
|||
e.printStackTrace();
|
||||
}
|
||||
agent.getListeTCPChat().remove(t);
|
||||
agent.getListeTCPChat2().remove(t);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -289,20 +329,6 @@ public class FenetreChat extends JFrame implements PropertyChangeListener{
|
|||
}
|
||||
|
||||
public static void fermer() {
|
||||
TCPChat t = null;
|
||||
/*try {
|
||||
|
||||
InetAddress adr = dest.getAddress();
|
||||
for(TCPChat tcp : agent.getListeTCPChat()) {
|
||||
if(tcp.getSocket().getInetAddress().equals(adr)) {
|
||||
t=tcp;
|
||||
}
|
||||
}
|
||||
t.getSocket().close();
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}*/
|
||||
frame.dispose();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ import java.awt.GridLayout;
|
|||
import java.awt.Image;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
|
@ -97,6 +100,21 @@ public class FenetreInscription implements ActionListener {
|
|||
JLabel text = new JLabel("Login: ", SwingConstants.CENTER);
|
||||
text.setForeground(Color.WHITE);
|
||||
text.setOpaque(false);
|
||||
loginfield.addKeyListener(new KeyAdapter() {
|
||||
public void keyTyped(KeyEvent e) {
|
||||
if(e.getKeyChar() =='?' || e.getKeyChar() == '&' || e.getKeyChar() == '/' || e.getKeyChar() =='=' || e.getKeyChar() == KeyEvent.VK_SPACE) {
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
});
|
||||
pseudofield.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
if(e.getKeyChar() =='?' || e.getKeyChar() == '&' || e.getKeyChar() == '/' || e.getKeyChar() =='=' ||e.getKeyChar() == KeyEvent.VK_SPACE ) {
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
});
|
||||
JLabel text2 = new JLabel("Pseudo: ", SwingConstants.CENTER);
|
||||
text2.setForeground(Color.WHITE);
|
||||
text2.setOpaque(false);
|
||||
|
|
|
@ -194,11 +194,12 @@ public class FenetreMenu {
|
|||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
new FenetreChat(agent, selected.toString());
|
||||
FenetreChat.getInstance(agent, selected.toString());
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
cb.setSelectedItem(agent.getUser().getPseudo());
|
||||
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue