package Package_Classes;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import com.birosoft.liquid.LiquidLookAndFeel;
public class Interface_Client implements Runnable {
final static int NULL = 0;
final static int DECONNECTE = 1;
final static int DECONNEXION = 2;
final static int EN_CONNEXION = 3;
final static int CONNEXION = 4;
final static String Message_Du_Statut [] = {"Erreur! Impossible de se connecter!", "Déconnecté", "En Déconnexion...", "En connexion...", "Connecté"};
static String IP_Hote = "172.16.200.15";
static int Port = 1234;
static int Statut_De_La_Connexion = DECONNECTE;
static boolean Est_Un_Hote = false;
static String Chaine_Du_Statut = Message_Du_Statut [Statut_De_La_Connexion];
static StringBuffer Ajouter = new StringBuffer ("");
static StringBuffer Envoyer = new StringBuffer ("");
final static Interface_Client Instance = new Interface_Client ();
final static String Fin_De_La_Session = new Character ((char)0).toString ();
static Dimension Ecran;
static JFrame Fenetre1;
static JLabel Label1, Label2, Label3, Label4;
static JTextField Edit1, Edit2, Edit3;
static JRadioButton Bouton_Radio1;
static JButton Bouton1, Bouton2;
static ButtonGroup Groupe1;
static JScrollPane Barre_De_Defilement1, Barre_De_Defilement2;
static JTextArea Memo1, Memo2;
static ServerSocket Socket_Serveur = null;
static Socket SOCKET = null;
static BufferedReader Arrivee = null;
static PrintWriter Depart = null;
static int Largeur_Ecran = 0;
static int Hauteur_Ecran = 0;
static int Indice = -1;
static String [] Informations1 = null;
static String [] Informations2 = null;
static boolean Variable_Logique = false;
static JTable Table;
public Interface_Client () {
}
public static void Initialisation_Interface1 () {
Fenetre1 = new JFrame ("Interface Client");
Fenetre1.setResizable (false);
Fenetre1.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
Fenetre1.getContentPane ().setLayout (null);
Fenetre1.setSize (new Dimension (340, 440));
Fenetre1.setLocation (new Point (350, 0));
Label1 = new JLabel ("Client");
Label1.setFont (new Font ("CALIBRI", 0, 20));
Label1.setBounds (0, 0, 160, 25);
Fenetre1.getContentPane ().add (Label1);
Label2 = new JLabel ("Adresse IP : ", 4);
Label2.setFont (new Font ("CALIBRI", 0, 18));
Label2.setBounds (0, 40, 100, 25);
Fenetre1.getContentPane ().add (Label2);
Edit1 = new JTextField (10);
Edit1.setText (IP_Hote);
Edit1.setEnabled (false);
Edit1.setBounds (100, 40, 220, 25);
Edit1.addFocusListener (new FocusAdapter () {
public void focusLost (FocusEvent e) {
Edit1.selectAll ();
if (Statut_De_La_Connexion != DECONNECTE) {
Changer_Etat_Erreur (NULL, true);
}
else {
IP_Hote = Edit1.getText ();
}
}
});
Fenetre1.getContentPane ().add (Edit1);
Label3 = new JLabel ("Port : ", 4);
Label3.setFont (new Font ("CALIBRI", 0, 18));
Label3.setBounds (0, 70, 100, 25);
Fenetre1.getContentPane ().add (Label3);
Edit2 = new JTextField (10);
Edit2.setEditable (false);
Edit2.setBounds (100, 70, 220, 25);
Edit2.setText ((new Integer (Port)).toString ());
Edit2.addFocusListener (new FocusAdapter () {
public void focusLost (FocusEvent e) {
if (Statut_De_La_Connexion != DECONNECTE) {
Changer_Etat_Erreur (NULL, true);
}
else {
int Tomporaire;
try {
Tomporaire = Integer.parseInt (Edit2.getText ());
Port = Tomporaire;
}
catch (NumberFormatException e1) {
Edit2.setText ((new Integer (Port)).toString ());
Fenetre1.repaint ();
}
}
}
});
Fenetre1.getContentPane ().add (Edit2);
ActionAdapter Evenement_Bouton_Radio = null;
Evenement_Bouton_Radio = new ActionAdapter () {
public void actionPerformed (ActionEvent e) {
if (Statut_De_La_Connexion != DECONNECTE) {
Changer_Etat_Erreur (NULL, true);
}
else {
Est_Un_Hote = e.getActionCommand ().equals ("host");
if (Est_Un_Hote) {
Edit1.setEnabled (false);
Edit1.setText ("localhost");
IP_Hote = "localhost";
}
else {
Edit1.setEnabled(true);
}
}
}
};
Bouton_Radio1 = new JRadioButton ("Accueil", false);
Bouton_Radio1.setVisible (false);
Bouton_Radio1.setMnemonic (KeyEvent.VK_A);
Bouton_Radio1.setActionCommand ("guest");
Bouton_Radio1.setBounds (0, 100, 150, 25);
Bouton_Radio1.addActionListener (Evenement_Bouton_Radio);
Groupe1 = new ButtonGroup ();
Groupe1.add (Bouton_Radio1);
Fenetre1.getContentPane ().add (Bouton_Radio1);
Evenement_Bouton_Radio = new ActionAdapter () {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand ().equals ("connect")) {
Changer_Etat_Erreur (EN_CONNEXION, true);
}
else {
Changer_Etat_Erreur (DECONNEXION, true);
}
}
};
Bouton1 = new JButton ("Connecter", new ImageIcon ("Icones/1.PNG"));
Bouton1.setMnemonic (KeyEvent.VK_C);
Bouton1.setActionCommand ("connect");
Bouton1.addActionListener (Evenement_Bouton_Radio);
Bouton1.setEnabled (true);
Bouton1.setBounds (5, 130, 160, 50);
Fenetre1.getContentPane ().add (Bouton1);
Bouton2 = new JButton ("Déconnecter", new ImageIcon ("Icones/2.PNG"));
Bouton2.setMnemonic (KeyEvent.VK_D);
Bouton2.setActionCommand ("disconnect");
Bouton2.addActionListener (Evenement_Bouton_Radio);
Bouton2.setEnabled (false);
Bouton2.setBounds (170, 130, 160, 50);
Fenetre1.getContentPane ().add (Bouton2);
Edit3 = new JTextField ();
Edit3.setBackground (Color.RED);
Edit3.setEditable (false);
Edit3.setBounds (0, 185, 25, 25);
Fenetre1.getContentPane ().add (Edit3);
Label4 = new JLabel ();
Label4.setVisible (false);
Label4.setFont (new Font ("CALIBRI", 0, 18));
Label4.setText (Message_Du_Statut [DECONNECTE]);
Label4.setBounds (30, 185, 200, 25);
Fenetre1.getContentPane ().add (Label4);
Memo1 = new JTextArea ();
Memo1.setEditable (false);
Memo1.setFont (new Font ("CALIBRI", 0, 16));
Barre_De_Defilement1 = new JScrollPane (Memo1);
Barre_De_Defilement1.setBounds (5, 220, 320, 90);
Fenetre1.getContentPane ().add (Barre_De_Defilement1);
Memo2 = new JTextArea ();
Memo2.setFont (new Font ("CALIBRI", 0, 16));
Memo2.addKeyListener (new KeyAdapter () {
public void keyTyped (KeyEvent e) {
if (e.getKeyChar () == Event.ENTER) {
Memo1.append ("Client dit : " + Memo2.getText ());
Envoyer_Chaine ("Client dit : " + Memo2.getText ());
Memo2.setText ("");
}
}
});
Barre_De_Defilement2 = new JScrollPane (Memo2);
Barre_De_Defilement2.setBounds (5, 315, 320, 90);
Fenetre1.getContentPane ().add (Barre_De_Defilement2);
Fenetre1.setVisible (true);
}
private static void Changer_Etat_Pas_Erreur (int Etat_Connexion, boolean Pas_Erreur) {
if (Etat_Connexion != NULL) {
Statut_De_La_Connexion = Etat_Connexion;
}
if (Pas_Erreur) {
Chaine_Du_Statut = Message_Du_Statut [Statut_De_La_Co
小贝德罗
- 粉丝: 86
- 资源: 1万+
最新资源
- ️ Vue.js 的 RxJS 集成 .zip
- java网站权限工作流管理系统源码带本地搭建教程数据库 MySQL源码类型 WebForm
- ️ 启动基于 Vite 的 Vue 项目的推荐方法.zip
- C语言结构体与联合体的应用及其内存管理技巧
- (已弃用)Vue.js 2.x 的最佳数据表,绝对不差 如果您喜欢,请给我们一颗星 !.zip
- java青少年活动中心管理系统源码数据库 MySQL源码类型 WebForm
- 国内手游新品洞察报告 游戏市场分析:类型、题材、IP使用与同质化
- OpenFOAM 开放泡沫中离心泵的性能仿真
- springboot095学生宿舍信息的系统.zip
- JAVA基于SpringBoot供货商城源码带小程序数据库 MySQL源码类型 WebForm
- 中国汽车消费者报告 汽车市场发展新趋势消费者行为分析
- GLFW+GLEW+OpenGL+Imgui环境配置极简教程(含文件及详细教程)
- 解读新经济十大议题 新经济知识领域云计算大数据技术革命与治理
- java基于SSM框架新闻管理系统源码数据库 MySQL源码类型 WebForm
- CH340編程器模塊驅動
- ADS模板工程文件(LoadLine版本)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈