Session de clavardage Presentable
This commit is contained in:
parent
e7c4a39a75
commit
0b3a40c717
5 changed files with 166 additions and 25 deletions
|
@ -6,5 +6,6 @@
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="module" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="lib" path="jgoodies-forms-1.8.0.jar" sourcepath="jgoodies-forms-1.8.0-sources.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
BIN
Implementation/jgoodies-forms-1.8.0-sources.jar
Normal file
BIN
Implementation/jgoodies-forms-1.8.0-sources.jar
Normal file
Binary file not shown.
BIN
Implementation/jgoodies-forms-1.8.0.jar
Normal file
BIN
Implementation/jgoodies-forms-1.8.0.jar
Normal file
Binary file not shown.
|
@ -1,12 +1,28 @@
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import com.jgoodies.forms.layout.FormLayout;
|
||||||
|
import com.jgoodies.forms.layout.ColumnSpec;
|
||||||
|
import com.jgoodies.forms.layout.RowSpec;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.Insets;
|
||||||
|
|
||||||
public class View_Clavardage {
|
public class View_Clavardage {
|
||||||
JFrame frame ;
|
JFrame frame ;
|
||||||
|
@ -18,36 +34,160 @@ public class View_Clavardage {
|
||||||
public View_Clavardage(ChatApp app, String User2) {
|
public View_Clavardage(ChatApp app, String User2) {
|
||||||
this.app = app ;
|
this.app = app ;
|
||||||
this.frame = new JFrame("ChatApp-AL-NM");
|
this.frame = new JFrame("ChatApp-AL-NM");
|
||||||
this.destination = this.app.getMe();
|
this.source = this.app.getMe();
|
||||||
this.source = Utilisateur.stringToUtilisateur(User2);
|
this.destination = Utilisateur.stringToUtilisateur(User2);
|
||||||
this.frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // FERME TOUTE LES FENETRES ATTENTION
|
this.frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // FERME TOUTE LES FENETRES ATTENTION
|
||||||
// fixer les dimensions de la fenetre
|
// fixer les dimensions de la fenetre
|
||||||
this.frame.setSize(new Dimension(394, 344));
|
this.frame.setSize(new Dimension(394, 344));
|
||||||
|
this.frame.setResizable(false);
|
||||||
|
|
||||||
wa = new WindowAdapter(){
|
wa = new WindowAdapter(){
|
||||||
public void windowClosing(WindowEvent e){
|
public void windowClosing(WindowEvent e){
|
||||||
int reponse = View_Courante.showConfirmDialog();
|
int reponse = View_Courante.showConfirmDialog();
|
||||||
if (reponse==0){
|
if (reponse==0){
|
||||||
try {
|
|
||||||
app.deconnexion();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
frame.dispose();
|
frame.dispose();
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
panel = new JPanel();
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||||
|
gridBagLayout.columnWidths = new int[]{394, 0};
|
||||||
|
gridBagLayout.rowHeights = new int[]{16, 220, 74, 0};
|
||||||
|
gridBagLayout.columnWeights = new double[]{0.0, Double.MIN_VALUE};
|
||||||
|
gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
|
frame.getContentPane().setLayout(gridBagLayout);
|
||||||
|
panel = new JPanel();
|
||||||
|
JTextArea textAreaSaisie = new JTextArea(5,3);
|
||||||
|
textAreaSaisie.setForeground(Color.LIGHT_GRAY);
|
||||||
|
textAreaSaisie.setFont(new Font("Lucida Grande", Font.ITALIC, 11));
|
||||||
|
textAreaSaisie.setText("Entrer du texte ici !!!");
|
||||||
|
JScrollPane scrollPane = new JScrollPane(textAreaSaisie);
|
||||||
|
JButton send = new JButton("Envoye");
|
||||||
|
frame.getRootPane().setDefaultButton(send);
|
||||||
|
send.addActionListener(new ActionListener(){
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
//UTILISER TCPENVOI
|
||||||
|
textAreaSaisie.setText("");
|
||||||
|
}});
|
||||||
|
JButton reset = new JButton("Vider");
|
||||||
|
reset.addActionListener(new ActionListener(){
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
textAreaSaisie.setText("");
|
||||||
|
}});
|
||||||
|
JLabel titre = new JLabel("Chat avec "+ this.destination.getPseudo(),SwingConstants.CENTER);
|
||||||
|
GridBagConstraints gbc_titre = new GridBagConstraints();
|
||||||
|
gbc_titre.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_titre.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_titre.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_titre.gridx = 0;
|
||||||
|
gbc_titre.gridy = 0;
|
||||||
|
frame.getContentPane().add(titre, gbc_titre);
|
||||||
|
JTextArea textAreaAffichage = new JTextArea(10,5);
|
||||||
|
textAreaAffichage.setText("");
|
||||||
|
JScrollPane scrollPaneAffichage = new JScrollPane(textAreaAffichage);
|
||||||
|
textAreaAffichage.setEditable(false);
|
||||||
|
GridBagConstraints gbc_textAreaAffichage = new GridBagConstraints();
|
||||||
|
gbc_textAreaAffichage.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_textAreaAffichage.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_textAreaAffichage.gridx = 0;
|
||||||
|
gbc_textAreaAffichage.gridy = 1;
|
||||||
|
frame.getContentPane().add(scrollPaneAffichage, gbc_textAreaAffichage);
|
||||||
|
panel.add(BorderLayout.CENTER, scrollPane);
|
||||||
|
//panel.add(scrollPane);
|
||||||
|
panel.add(BorderLayout.SOUTH,send);
|
||||||
|
panel.add(BorderLayout.SOUTH,reset);
|
||||||
|
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
||||||
|
//Add the panel to the window.
|
||||||
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
||||||
|
gbc_panel.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_panel.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_panel.gridx = 0;
|
||||||
|
gbc_panel.gridy = 2;
|
||||||
|
frame.getContentPane().add(panel, gbc_panel);
|
||||||
|
//addWidgets();
|
||||||
frame.addWindowListener( wa ) ;
|
frame.addWindowListener( wa ) ;
|
||||||
//Add the widgets.
|
|
||||||
this.addWidgets();
|
|
||||||
|
|
||||||
//Add the panel to the window.
|
|
||||||
frame.getContentPane().add(this.panel, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
//Display the window.
|
|
||||||
//frame.pack();
|
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
private void addWidgets() {}
|
private void addWidgets() {
|
||||||
|
panel = new JPanel();
|
||||||
|
JTextArea textAreaSaisie = new JTextArea(5,5);
|
||||||
|
textAreaSaisie.setForeground(Color.LIGHT_GRAY);
|
||||||
|
textAreaSaisie.setFont(new Font("Lucida Grande", Font.ITALIC, 11));
|
||||||
|
textAreaSaisie.setText("Entrer du texte ici !!!");
|
||||||
|
JScrollPane scrollPane = new JScrollPane(textAreaSaisie);
|
||||||
|
JButton send = new JButton("Envoye");
|
||||||
|
frame.getRootPane().setDefaultButton(send);
|
||||||
|
send.addActionListener(new ActionListener(){
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
//UTILISER TCPENVOI
|
||||||
|
textAreaSaisie.setText("");
|
||||||
|
}});
|
||||||
|
JButton reset = new JButton("Vider");
|
||||||
|
reset.addActionListener(new ActionListener(){
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
textAreaSaisie.setText("");
|
||||||
|
}});
|
||||||
|
JLabel titre = new JLabel("Chat avec "+ this.destination.getPseudo(),SwingConstants.CENTER);
|
||||||
|
GridBagConstraints gbc_titre = new GridBagConstraints();
|
||||||
|
gbc_titre.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_titre.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_titre.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_titre.gridx = 0;
|
||||||
|
gbc_titre.gridy = 0;
|
||||||
|
frame.getContentPane().add(titre, gbc_titre);
|
||||||
|
JTextArea textAreaAffichage = new JTextArea(10,5);
|
||||||
|
textAreaAffichage.setEditable(false);
|
||||||
|
GridBagConstraints gbc_textAreaAffichage = new GridBagConstraints();
|
||||||
|
gbc_textAreaAffichage.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc_textAreaAffichage.insets = new Insets(0, 0, 5, 0);
|
||||||
|
gbc_textAreaAffichage.gridx = 0;
|
||||||
|
gbc_textAreaAffichage.gridy = 1;
|
||||||
|
frame.getContentPane().add(textAreaAffichage, gbc_textAreaAffichage);
|
||||||
|
panel.add(BorderLayout.CENTER, scrollPane);
|
||||||
|
//panel.add(scrollPane);
|
||||||
|
panel.add(BorderLayout.SOUTH,send);
|
||||||
|
panel.add(BorderLayout.SOUTH,reset);
|
||||||
|
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
||||||
|
//Add the panel to the window.
|
||||||
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
||||||
|
gbc_panel.anchor = GridBagConstraints.NORTH;
|
||||||
|
gbc_panel.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc_panel.gridx = 0;
|
||||||
|
gbc_panel.gridy = 2;
|
||||||
|
frame.getContentPane().add(panel, gbc_panel);
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*JTextArea textAreaAffichage = new JTextArea(10,5);
|
||||||
|
textAreaAffichage.setEditable(false);
|
||||||
|
JTextArea textAreaSaisie = new JTextArea(10,5);
|
||||||
|
textAreaSaisie.setForeground(Color.LIGHT_GRAY);
|
||||||
|
textAreaSaisie.setFont(new Font("Lucida Grande", Font.ITALIC, 11));
|
||||||
|
textAreaSaisie.setText("Entrer du texte ici !!!");
|
||||||
|
JScrollPane scrollPane = new JScrollPane(textAreaSaisie);
|
||||||
|
JButton send = new JButton("Envoye");
|
||||||
|
frame.getRootPane().setDefaultButton(send);
|
||||||
|
send.addActionListener(new ActionListener(){
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
//UTILISER TCPENVOI
|
||||||
|
textAreaSaisie.setText("");
|
||||||
|
}});
|
||||||
|
JButton reset = new JButton("Vider");
|
||||||
|
reset.addActionListener(new ActionListener(){
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
textAreaSaisie.setText("");
|
||||||
|
}});
|
||||||
|
JLabel titre = new JLabel("Chat avec "+ this.destination.getPseudo(),SwingConstants.CENTER);
|
||||||
|
panel.add(BorderLayout.CENTER, scrollPane);
|
||||||
|
//panel.add(scrollPane);
|
||||||
|
panel.add(BorderLayout.SOUTH,send);
|
||||||
|
panel.add(BorderLayout.SOUTH,reset);
|
||||||
|
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
||||||
|
//Add the panel to the window.
|
||||||
|
frame.getContentPane().add(BorderLayout.SOUTH, panel);
|
||||||
|
frame.getContentPane().add(BorderLayout.CENTER, textAreaAffichage);
|
||||||
|
frame.getContentPane().add(BorderLayout.NORTH, titre);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,25 +129,25 @@ public class View_Courante {
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
JPanel panel1 = new JPanel();
|
JPanel panel1 = new JPanel();
|
||||||
JButton home = new JButton(new ImageIcon("/Users/auriane/Desktop/ChatApp-AL-NM/Implementation/src/images/Home.png"));
|
JButton home = new JButton(new ImageIcon("/Users/auriane/Desktop/ChatApp-AL-NM/Implementation/src/images/Home.png"));
|
||||||
panel1.add(BorderLayout.NORTH , home);
|
|
||||||
|
|
||||||
JLabel Text = new JLabel("<html> Liste Utilisateurs Actifs <br/> <html>");
|
JTextArea textArea = new JTextArea(20,20);
|
||||||
panel1.add(Text);
|
textArea.insert("Liste Utilisateurs Actifs \n",0);
|
||||||
|
JScrollPane scrollPane = new JScrollPane(textArea);
|
||||||
|
|
||||||
String utilisateurs = app.getActifUsers().afficherListeUtilisateurs();
|
String utilisateurs = app.getActifUsers().afficherListeUtilisateurs();
|
||||||
for(String elem : utilisateurs.split("\n")) {
|
for(String elem : utilisateurs.split("\n")) {
|
||||||
JLabel Text1 = new JLabel("<html>" + elem + "<br/> <html>");
|
textArea.append( " - " +Utilisateur.stringToUtilisateur(elem).getPseudo() + '\n');
|
||||||
panel1.add(Text1);
|
|
||||||
}
|
}
|
||||||
|
panel1.add(textArea);
|
||||||
home.addActionListener(new ActionListener(){
|
home.addActionListener(new ActionListener(){
|
||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
frame.dispose();
|
frame.dispose();
|
||||||
new View_Courante(app);
|
new View_Courante(app);
|
||||||
} });
|
} });
|
||||||
|
textArea.setEditable(false);
|
||||||
frame.getContentPane().removeAll();
|
frame.getContentPane().removeAll();
|
||||||
frame.getContentPane().add(panel1);
|
frame.getContentPane().add(BorderLayout.CENTER, panel1);
|
||||||
|
frame.getContentPane().add(BorderLayout.NORTH , home);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue