📄 chatdialog.java
字号:
package client;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Color;
import java.awt.Rectangle;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.Font;
import javax.swing.JTextArea;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import java.awt.Toolkit;
import javax.swing.JScrollPane;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.border.SoftBevelBorder;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.net.DatagramSocket;
import java.text.SimpleDateFormat;
import java.util.Date;
public class ChatDialog extends JFrame {
private static final long serialVersionUID = 112341312432L;
private JPanel jContentPane = null;
private JPanel jPanel = null;
private JPanel jPanel2 = null;
private JPanel jPanel3 = null;
private JPanel jPanel4 = null;
private JPanel jPanel5 = null;
private JPanel jPanel7 = null;
private JLabel jLabel12 = null;
private JButton jButton = null;
private JButton jButton1 = null;
private JScrollPane jScrollPane = null;
private JTextArea jTextArea = null;
private JScrollPane jScrollPane1 = null;
private JTextArea jTextArea1 = null;
private JMenuBar jJMenuBar = null;
private JMenu jMenu = null;
private JMenuItem jMenuItem = null;
private JMenuItem jMenuItem1 = null;
private JMenu jMenu1 = null;
private JMenuItem jMenuItem2 = null;
private JMenuItem jMenuItem3 = null;
private JMenu jMenu2 = null;
private JMenuItem jMenuItem4 = null;
private JMenuItem jMenuItem5 = null;
private JMenu jMenu3 = null;
private JMenuItem jMenuItem6 = null;
private JMenuItem jMenuItem7 = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JLabel jLabel24 = null;
private JLabel jLabel3 = null;
private JLabel jLabel191 = null;
private JLabel jLabel201 = null;
private JLabel jLabel211 = null;
private JLabel jLabel221 = null;
private JLabel jLabel91 = null;
private JLabel jLabel112 = null;
private JLabel jLabel181 = null;
private JLabel jLabel141 = null;
private JLabel jLabel151 = null;
private JLabel jLabel101 = null;
private JLabel jLabel161 = null;
private JLabel jLabel171 = null;
private JLabel jLabel131 = null;
private JButton jButton11 = null;
private DatagramSocket dSocket = null;
private Controller controller = null;
private int qq = 0;
private int n = 0;
private ChatLog chatLog = null;
/**
* This is the default constructor
*/
public ChatDialog(Controller controller, int qq, DatagramSocket dSocket) {
super();
initialize();
this.setTitle("与" + qq + "聊天中...");
this.controller = controller;
this.qq = qq;
this.dSocket = dSocket;
if (chatLog == null) {
chatLog = new ChatLog(this);
}
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setJMenuBar(getJJMenuBar());
this
.setIconImage(Toolkit.getDefaultToolkit().getImage(
getClass().getResource(
"/picture/IMSmallToolbarPicForbid.gif")));
this.setResizable(false);
this.setBounds(new Rectangle(300, 300, 580, 500));
this.setContentPane(getJContentPane());
this.setVisible(false);
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
chatLog.getJTextArea().append(jTextArea.getText());
jTextArea.setText("");
ChatDialog.this.dispose();
}
});
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel24 = new JLabel();
jLabel24.setBounds(new Rectangle(430, 224, 134, 15));
jLabel24.setText("自己形象");
jLabel2 = new JLabel();
jLabel2.setText("对方形象");
jLabel2.setBounds(new Rectangle(430, 16, 134, 15));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setBackground(new Color(169, 213, 244));
jContentPane.add(getJPanel(), null);
jContentPane.add(getJPanel2(), null);
jContentPane.add(getJPanel3(), null);
jContentPane.add(getJPanel4(), null);
jContentPane.add(getJPanel5(), null);
jContentPane.add(getJPanel7(), null);
jContentPane.add(getJButton1(), null);
jContentPane.add(jLabel24, null);
jContentPane.add(getJButton11(), null);
}
return jContentPane;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jLabel221 = new JLabel();
jLabel221.setBounds(new Rectangle(200, 3, 30, 30));
jLabel221.setText("");
jLabel221.setHorizontalAlignment(SwingConstants.CENTER);
jLabel221.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMBigToolbarSendFile.gif")));
jLabel211 = new JLabel();
jLabel211.setBounds(new Rectangle(140, 3, 30, 30));
jLabel211.setText("");
jLabel211.setHorizontalAlignment(SwingConstants.CENTER);
jLabel211.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMBigToolbarQQSQQ.gif")));
jLabel201 = new JLabel();
jLabel201.setBounds(new Rectangle(80, 3, 30, 30));
jLabel201.setText("");
jLabel201.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
jLabel201.setHorizontalAlignment(SwingConstants.CENTER);
jLabel201.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel201.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMBigToolbarVideo.gif")));
jLabel191 = new JLabel();
jLabel191.setBounds(new Rectangle(20, 3, 30, 30));
jLabel191.setText("");
jLabel191.setHorizontalAlignment(SwingConstants.CENTER);
jLabel191.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel191.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMBigToolbarMQQ.gif")));
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.setBounds(new Rectangle(2, 1, 569, 34));
jPanel.setBorder(BorderFactory.createLineBorder(new Color(118, 171,
211), 1));
jPanel.setBackground(new Color(102, 197, 251));
jPanel.add(jLabel191, null);
jPanel.add(jLabel201, null);
jPanel.add(jLabel211, null);
jPanel.add(jLabel221, null);
jPanel.add(jLabel2, null);
}
return jPanel;
}
/**
* This method initializes jPanel2
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel2() {
if (jPanel2 == null) {
jPanel2 = new JPanel();
jPanel2.setLayout(null);
jPanel2.setBounds(new Rectangle(5, 35, 410, 245));
jPanel2.setBorder(BorderFactory.createLineBorder(new Color(118,
171, 211), 1));
jPanel2.setBackground(Color.white);
jPanel2.add(getJScrollPane(), null);
}
return jPanel2;
}
/**
* This method initializes jPanel3
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel3() {
if (jPanel3 == null) {
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(4, 4, 128, 182));
jLabel1.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
jLabel1.setIcon(new ImageIcon(getClass().getResource(
"/picture/39375662.gif")));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel1.setText("");
jPanel3 = new JPanel();
jPanel3.setLayout(null);
jPanel3.setBounds(new Rectangle(430, 35, 135, 189));
jPanel3.setBackground(Color.white);
jPanel3.setBorder(BorderFactory.createCompoundBorder(BorderFactory
.createLineBorder(Color.pink, 2), new SoftBevelBorder(
SoftBevelBorder.LOWERED)));
jPanel3.add(jLabel1, null);
}
return jPanel3;
}
/**
* This method initializes jPanel4
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel4() {
if (jPanel4 == null) {
jLabel131 = new JLabel();
jLabel131.setBounds(new Rectangle(163, 2, 20, 20));
jLabel131.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel131.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMSmallToolbarPicture.gif")));
jLabel131.setText("");
jLabel131.setHorizontalAlignment(SwingConstants.CENTER);
jLabel171 = new JLabel();
jLabel171.setBounds(new Rectangle(290, 3, 20, 20));
jLabel171.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel171.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMSmallToolbarPresent.gif")));
jLabel171.setText("");
jLabel171.setHorizontalAlignment(SwingConstants.CENTER);
jLabel161 = new JLabel();
jLabel161.setBounds(new Rectangle(260, 2, 20, 20));
jLabel161.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel161.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMSmallToolbarQRing.gif")));
jLabel161.setText("");
jLabel161.setHorizontalAlignment(SwingConstants.CENTER);
jLabel101 = new JLabel();
jLabel101.setBounds(new Rectangle(36, 2, 20, 20));
jLabel101.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel101.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMSmallToolbarFace.gif")));
jLabel101.setText("");
jLabel101.setHorizontalAlignment(SwingConstants.CENTER);
jLabel151 = new JLabel();
jLabel151.setBounds(new Rectangle(228, 2, 20, 20));
jLabel151.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel151.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMSmallToolbarScene.gif")));
jLabel151.setText("");
jLabel151.setHorizontalAlignment(SwingConstants.CENTER);
jLabel141 = new JLabel();
jLabel141.setBounds(new Rectangle(196, 2, 20, 20));
jLabel141.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel141.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMSmallToolbarCatch.gif")));
jLabel141.setText("");
jLabel141.setHorizontalAlignment(SwingConstants.CENTER);
jLabel181 = new JLabel();
jLabel181.setBounds(new Rectangle(131, 2, 20, 20));
jLabel181.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel181.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMSmallToolbarQuick.gif")));
jLabel181.setText("");
jLabel181.setHorizontalAlignment(SwingConstants.CENTER);
jLabel112 = new JLabel();
jLabel112.setBounds(new Rectangle(68, 2, 20, 20));
jLabel112.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel112.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMSmallToolbarOtherContent.gif")));
jLabel112.setText("");
jLabel112.setHorizontalAlignment(SwingConstants.CENTER);
jLabel91 = new JLabel();
jLabel91.setBounds(new Rectangle(5, 2, 20, 20));
jLabel91.setForeground(new Color(211, 239, 255));
jLabel91.setHorizontalAlignment(SwingConstants.CENTER);
jLabel91.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel91.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMSmallToolbarFont.gif")));
jLabel91.setText("");
jLabel91.setBackground(new Color(211, 239, 255));
jLabel12 = new JLabel();
jLabel12.setIcon(new ImageIcon(getClass().getResource(
"/picture/IMSmallToolbarShakeWin.gif")));
jLabel12.setHorizontalAlignment(SwingConstants.CENTER);
jLabel12.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel12.setBounds(new Rectangle(98, 2, 20, 20));
jLabel12.setText("");
jPanel4 = new JPanel();
jPanel4.setLayout(null);
jPanel4.setBounds(new Rectangle(6, 281, 408, 25));
jPanel4.setBackground(new Color(211, 239, 255));
jPanel4.setBorder(BorderFactory.createLineBorder(Color.white, 0));
jPanel4.add(jLabel91, null);
jPanel4.add(jLabel112, null);
jPanel4.add(jLabel181, null);
jPanel4.add(jLabel141, null);
jPanel4.add(jLabel151, null);
jPanel4.add(jLabel101, null);
jPanel4.add(jLabel161, null);
jPanel4.add(jLabel171, null);
jPanel4.add(jLabel131, null);
jPanel4.add(jLabel12, null);
jPanel4.add(getJButton(), null);
}
return jPanel4;
}
/**
* This method initializes jPanel5
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel5() {
if (jPanel5 == null) {
jPanel5 = new JPanel();
jPanel5.setLayout(null);
jPanel5.setBounds(new Rectangle(5, 305, 410, 90));
jPanel5.setBackground(Color.white);
jPanel5.setBorder(BorderFactory.createLineBorder(new Color(118,
171, 211), 1));
jPanel5.add(getJScrollPane1(), null);
}
return jPanel5;
}
/**
* This method initializes jPanel7
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel7() {
if (jPanel7 == null) {
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(4, 3, 128, 180));
jLabel3.setIcon(new ImageIcon(getClass().getResource(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -