package chat;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.swing.border.*;
import java.lang.Exception;
import java.net.*;
import java.io.*;
import java.util.Date;
import javax.swing.event.*;
/**
* <p>Title: 使用JAVA制作的局域网聊天程序</p>
* <p>Description: 我们的JAVA作业</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author RoadAhead
* @version 1.0
*/
public class mainform extends JFrame
{
private JPanel contentPane;
static JPanel jPanel1 = new JPanel();
private JPanel jPanel2 = new JPanel();
private JButton but_online = new JButton();
private BorderLayout borderLayout2 = new BorderLayout();
private JMenuBar jMenuBar1 = new JMenuBar();
static JSplitPane jsp8 = new JSplitPane();
private JPanel jPanel5 = new JPanel();
private JButton but_exit = new JButton();
private JMenu jMenu1 = new JMenu();
private JButton but_offline = new JButton();
private JButton but_about = new JButton();
private JPanel pan_state = new JPanel();
static JTextPane ed_input = new JTextPane();
private PaneLayout paneLayout1 = new PaneLayout();
private TitledBorder titledBorder1;
private TitledBorder titledBorder2;
static Label lab_uname = new Label();
static JLabel lab_uimage = new JLabel();
private JLabel jLabel2 = new JLabel();
private JLabel lab_info = new JLabel();
static final int PORT=5001;
static String curuserip="";
static String curusername="";
static String curusericon="";
static String myname="";
static String myicon="";
static String myip;
static String onstartset="";
static String filename="chatset.amy";
static String winstate="0";
static int maxStrCount=10000;
static int onlinestate=2;//是否在线 1: 在线 2:断线 3: 离线
static String onofflinetime=""; //当离线时的回答
private JButton but_setup = new JButton();
static String[][] userlist;//用户列表
static JButton[] but_userlist; //用户图象按钮
private JScrollPane jsp = new JScrollPane();
static JPanel pan_userlist = new JPanel();
private TitledBorder titledBorder3;
private PaneLayout paneLayout2 = new PaneLayout();
static JLabel lab_my = new JLabel();
private TitledBorder titledBorder4;
newthread mythread=new newthread();
static DatagramPacket sendpacket,receivepacket;
static DatagramSocket sendsocket,receivesocket;
private JScrollPane jScrollPane1 = new JScrollPane();
static JTextArea ed_show = new JTextArea();
private JCheckBox cbo_bc = new JCheckBox();
private JScrollPane jScrollPane2 = new JScrollPane();
JOptionPane pane = new JOptionPane();
Date nowtime=new Date();
private JPopupMenu pop_menu = new JPopupMenu();
private JMenuItem jMenuItem1 = new JMenuItem();
private JMenuItem jMenuItem2 = new JMenuItem();
private JButton but_pause = new JButton();
private BoxLayout2 boxLayout21 = new BoxLayout2();
private Label label1 = new Label();
private Label label2 = new Label();
private BorderLayout borderLayout1 = new BorderLayout();
VerticalFlowLayout verticalFlowLayout1 = new VerticalFlowLayout();
//Construct the frame
public mainform()
{
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception
{
try{
sendsocket=new DatagramSocket();
receivesocket=new DatagramSocket(5001);
}
catch(SocketException se){
se.printStackTrace();
}
mainform.userlist=new String[1][5];
but_userlist=new JButton [1];
//setIconImage(Toolkit.getDefaultToolkit().createImage(mainform.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
titledBorder1 = new TitledBorder("");
titledBorder2 = new TitledBorder("");
titledBorder3 = new TitledBorder("");
titledBorder4 = new TitledBorder("");
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(523, 356));
this.setTitle("我们的聊天程序 Alt+Enter 发送消息");
this.addWindowListener(new java.awt.event.WindowAdapter()
{
public void windowOpened(WindowEvent e)
{
this_windowOpened(e);
}
public void windowActivated(WindowEvent e)
{
}
});
jPanel1.setBackground(Color.white);
jPanel1.setLayout(borderLayout2);
jPanel2.setBackground(Color.white);
jPanel2.setBorder(titledBorder4);
jPanel2.setToolTipText("");
jPanel2.setLayout(paneLayout2);
but_online.setBackground(Color.white);
but_online.setFont(new java.awt.Font("Serif", 0, 12));
but_online.setBorder(null);
but_online.setHorizontalTextPosition(SwingConstants.CENTER);
but_online.setText("在线");
but_online.setVerticalAlignment(SwingConstants.BOTTOM);
but_online.setVerticalTextPosition(SwingConstants.BOTTOM);
but_online.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseExited(MouseEvent e)
{
but_online_mouseExited(e);
}
});
but_online.addMouseMotionListener(new java.awt.event.MouseMotionAdapter()
{
public void mouseMoved(MouseEvent e)
{
but_online_mouseMoved(e);
}
});
but_online.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
but_online_actionPerformed(e);
}
});
jsp8.setBorder(null);
jsp8.setContinuousLayout(true);
jsp8.setDividerSize(2);
jsp8.setLeftComponent(pan_userlist);
but_exit.setBackground(Color.white);
but_exit.setFont(new java.awt.Font("Serif", 0, 12));
but_exit.setBorder(null);
but_exit.setHorizontalTextPosition(SwingConstants.CENTER);
but_exit.setText("退出");
but_exit.setVerticalAlignment(SwingConstants.BOTTOM);
but_exit.setVerticalTextPosition(SwingConstants.BOTTOM);
but_exit.addMouseMotionListener(new java.awt.event.MouseMotionAdapter()
{
public void mouseMoved(MouseEvent e)
{
but_exit_mouseMoved(e);
}
});
but_exit.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
but_exit_mousePressed(e);
}
public void mouseExited(MouseEvent e)
{
but_exit_mouseExited(e);
}
});
but_exit.addKeyListener(new java.awt.event.KeyAdapter()
{
public void keyTyped(KeyEvent e)
{
but_exit_keyTyped(e);
}
});
jMenu1.setText("文件");
but_offline.setBackground(Color.white);
but_offline.setFont(new java.awt.Font("Serif", 0, 12));
but_offline.setBorder(null);
but_offline.setHorizontalTextPosition(SwingConstants.CENTER);
but_offline.setText("断线");
but_offline.setVerticalAlignment(SwingConstants.BOTTOM);
but_offline.setVerticalTextPosition(SwingConstants.BOTTOM);
but_offline.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseExited(MouseEvent e)
{
but_offline_mouseExited(e);
}
});
but_offline.addMouseMotionListener(new java.awt.event.MouseMotionAdapter()
{
public void mouseMoved(MouseEvent e)
{
but_offline_mouseMoved(e);
}
});
but_offline.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
but_offline_actionPerformed(e);
}
});
but_about.setBackground(Color.white);
but_about.setFont(new java.awt.Font("Serif", 0, 12));
but_about.setBorder(null);
but_about.setHorizontalTextPosition(SwingConstants.CENTER);
but_about.setText("关于这个程序");
but_about.setVerticalAlignment(SwingConstants.BOTTOM);
but_about.setVerticalTextPosition(SwingConstants.BOTTOM);
but_about.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseExited(MouseEvent e)
{
but_about_mouseExited(e);
}
});
but_about.addMouse
luoshengqian
- 粉丝: 9
- 资源: 21
最新资源
- 【java毕业设计】校园资产管理源码(springboot+vue+mysql+说明文档+LW).zip
- 【java毕业设计】人事管理系统源码(springboot+vue+mysql+说明文档+LW).zip
- 问题- pip install pyqt6-tool失败.pdf
- 【java毕业设计】老年一站式服务平台源码(springboot+vue+mysql+说明文档).zip
- 【java毕业设计】科研项目验收管理系统源码(springboot+vue+mysql+说明文档+LW).zip
- java电商书城系统源码带本地搭建教程数据库 MySQL源码类型 WebForm
- 小熊派读取浊度、TDS、PH值和温湿度传感器的数据
- 【java毕业设计】智慧生活商城系统设计与实现源码(springboot+vue+mysql+说明文档+LW).zip
- 基于RBAC模型的权限控制的一整套基础开发平台,前后端分离,后端采用 django+django-rest-framework,前端采用 vue+ElementUI
- 扰动观测器(时域)-Matlab/Simulink开发
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论2