首页>代码>java swing仿qq写的群聊软件>/javaqq/src/Clientframe.java
import java.awt.BorderLayout;
import java.awt.Checkbox;
import java.awt.Choice;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.TextArea;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;

/**
 * 
 * @author tian
 *	
 */
public class Clientframe {
	
	//	��½����
	JFrame jf;
	JPanel jp1;			
	JPanel jp2;
	JLabel jl1;			
	JLabel jl2;			
	JLabel jl3;
	JLabel jl4;
	JLabel jl5;
	JLabel jl6;
	JLabel jl7;
	Checkbox cb;
	Checkbox cb2;
	Choice ci ;
	ImageIcon im;
	JLabel jl8;
	JTextField jtfname;	
	JPasswordField jtfpwd;	
	JTextField jtfname2;
	JTextField jtfname3;
	JButton jb1;		
	JButton jb2;
	
//	  Ⱥ�Ĵ���
	JFrame jfa;
	JPanel jpa;
	JPanel jp;
	JPanel jpl;
	TextArea jtaa;
	TextArea jtab;
	JButton jba;
	JButton jbb;
	JButton jbc;
	JTextPane textPane;
	JTextPane textPane1;	
	ImageIcon iic;
	
//	  ˽�Ĵ���
	JFrame jfaa;			
	JPanel jpaa;			
	JPanel jpp;
	JPanel jpll;
	JTextPane jtaaa;	
	JTextPane jtabb;	
	JButton jbaa;		
	JButton jbbb;		
	JButton jbbc;
	ImageIcon iic2;
	
//	  �����û��б�
	JFrame jfb;
	JPanel jpan;
	JPanel jpan1;
	DefaultListModel dlm;
	JList jli;
	JButton jb;
	ImageIcon ii;
	ImageIcon iii;
	JLabel jl;
	
//	Ⱥ�ı��鴰��
	JFrame jfc;
	JPanel jpbq;
	
	/**
	 * 
	 */
	public Clientframe(){
		
//		��ʼ��Ⱥ�ı��鴰��
		jfc = new JFrame("����");
		jpbq = new JPanel();
		jfc.add(jpbq, BorderLayout.CENTER);
		jpbq.setLayout(new GridLayout(5,5));
		jfc.add(jpbq);
		URL qqurl = this.getClass().getClassLoader().getResource("Image/qq.jpg"); 
		jfc.setIconImage(Toolkit.getDefaultToolkit().createImage(qqurl));
		ArrayList al = new ArrayList();
		for (int i = 10; i < 35; i++) {
			URL url = this.getClass().getClassLoader().getResource( "Image/"+i+".gif"); 
			ImageIcon ii=new ImageIcon(url);
			JLabel jl = new JLabel(ii);
			al.add(jl);
		}
		for (int j = 0; j < al.size(); j++) {
			JLabel jl = (JLabel) al.get(j);
			jl.addMouseListener(new MouseListener(){
				public void mouseClicked(MouseEvent e) {
					StyledDocument doc = textPane1.getStyledDocument();
					SimpleAttributeSet attr = new SimpleAttributeSet();
					StyleConstants.setForeground(attr, Color.red);
					String s = e.getSource().toString();
					Pattern p = Pattern.compile(".gif");
					Matcher m = p.matcher(s);
					while(m.find()){
							int start = m.start();
							int end = m.end();
							String subs = s.substring(start-2,end);
							String path = "d:\\"+subs;
							textPane1.setCaretPosition(doc.getLength()); // ���ò���λ��
							File file = new File(path);
							Icon image = new ImageIcon(file.getAbsoluteFile().toString());
							textPane1.insertIcon(image);
							try {
								doc.insertString(doc.getLength(), file.getName(), attr);
							} catch (BadLocationException e1) {
								
								e1.printStackTrace();
							}
						}
				}

				public void mouseEntered(MouseEvent e) {
					
				}
			
				public void mouseExited(MouseEvent e) {
					
				}

				public void mousePressed(MouseEvent e) {
					
				}

				public void mouseReleased(MouseEvent e) {
					
				}
			});
			jpbq.add(jl);
		}
		
		jfc.setVisible(false);
		jfc.setSize(250,250);

		
//		��ʼ����½����
		
		jf = new JFrame("QQ�û���½");
		jp1 = new JPanel();
		jp2 = new JPanel();
		jtfname = new JTextField("",15);
		jtfpwd = new JPasswordField("",15);
		jtfname2 = new JTextField("",15);
		jl1 = new JLabel("QQ�˺�:");
		jl2 = new JLabel("QQ����:");
		jl3 = new JLabel("ServerIP:");
		jl4 = new JLabel("�����˺�");
	    jl5 = new JLabel("��������");
		jl6 = new JLabel("QQ״̬��");
		jl7=new JLabel("���еش� ");
		cb = new Checkbox("�Զ���¼");
	    cb2 = new Checkbox("��ס����");
		ci = new Choice();
		jb1 = new JButton("��¼");
        jb2 = new JButton("�˳�");
        URL jmurl =this.getClass().getClassLoader().getResource("Image/jm.jpg");
        im = new ImageIcon(jmurl);
        jl8=new JLabel(im);
		jf.add(jp1,BorderLayout.CENTER);
		jf.add(jp2,BorderLayout.SOUTH);
		jp1.add(jl8);
		jp1.add(jl1);
		jp1.add(jtfname);
		jp1.add(jl4);
		jp1.add(jl2);
		jp1.add(jtfpwd);
		jp1.add(jl5);
		jp1.add(jl3);
		jp1.add(jtfname2);
		jp1.add(jl7);
		jp1.add(jl6);
		jp1.add(ci);
		jp1.add(cb2);
		jp1.add(cb);
		jp2.add(jb1);
		jp2.add(jb2);
		jf.setBackground(new Color(100, 253, 98));
		jp1.setBackground(new Color(176, 224, 230 ));
		jp2.setBackground(new Color(127, 255, 212 ));
		ci.add("����");
		ci.add("Q�Ұ�");
		ci.add("æµ");
		ci.add("�뿪");
		ci.add("����");
		ci.add("����");
		jl1.setForeground(Color.BLUE);
		jl2.setForeground(Color.BLUE);
		jl3.setForeground(Color.BLUE);
		jl4.setForeground(Color.BLUE);
		jl5.setForeground(Color.BLUE);
		jl7.setForeground(Color.BLUE);
		jb1.setSize(20, 10);
		jb2.setSize(20, 10);
        jf.setSize(333, 250);
		jf.setIconImage(Toolkit.getDefaultToolkit().createImage(qqurl));
		jf.setLocation(500, 250);
		jf.setResizable(false);
		jf.setVisible(true);
		
		jb2.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				System.exit(1);
				
			}
			
		});
		
//		��ʼ��Ⱥ�Ĵ���
		jfa = new JFrame("QQ������");
		jpa = new JPanel();
		jp = new JPanel();
		jpl = new JPanel();
		dlm = new DefaultListModel();
		URL iicurl =this.getClass().getClassLoader().getResource("Image/12.gif");
		iic=new ImageIcon(iicurl);
		textPane = new JTextPane();
		textPane1 = new JTextPane();
		textPane.setPreferredSize(new Dimension(360, 200));
		textPane1.setPreferredSize(new Dimension(360, 100));
		textPane.setFont(new Font("Serif",Font.BOLD,14));
		textPane1.setFont(new Font("Serif",Font.BOLD,14));
		JScrollPane scrollPane = new JScrollPane(textPane);
		JScrollPane scrollPane1 = new JScrollPane(textPane1);
		textPane1.setForeground(Color.red);
		jba = new JButton("����");
		jbb = new JButton("���");
		jbc = new JButton("����",iic);
		jbc.setMnemonic(KeyEvent.VK_F);//����顱��ť���ÿ�ݼ�
		jba.setForeground(Color.BLUE);
		jbb.setForeground(Color.BLUE);
		jbc.setForeground(Color.BLUE);
		jfa.add(jpa, BorderLayout.NORTH);
		jfa.add(jp, BorderLayout.CENTER);
		jfa.add(jpl, BorderLayout.SOUTH);
		jfa.setIconImage(Toolkit.getDefaultToolkit().createImage(qqurl));
		jpa.add(scrollPane);
		jp.add(scrollPane1);
		jpl.add(jba);
		jpl.add(jbc);
		jpl.add(jbb);
		jpa.setBackground(new Color(100, 253, 98));
		jp.setBackground(new Color(100, 253, 98));
		jpl.setBackground(new Color(100, 253, 98));
		jfa.setSize(380, 400);
		jfa.setLocation(500, 150);
		jfa.setResizable(false);
		jfa.setVisible(false);

		jbb.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				textPane1.setText("");
			}
		});
		
		
//		 ����Ⱥ�ı��鰴ť
		jbc.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				jfc.setVisible(true);
				jfc.setLocation(500, 150);
			}
		});
		
//		��ʼ��˽�Ĵ���
		jfaa = new JFrame("˽��");			
		jpaa = new JPanel();			
		jpp = new JPanel();
		jpll =new JPanel();
		URL transcurl =this.getClass().getClassLoader().getResource("Image/trans.gif");
		iic2 =new ImageIcon(transcurl);
		jtaaa = new JTextPane();	
		jtabb = new JTextPane();
		jtaaa.setPreferredSize(new Dimension(360, 200));
		jtabb.setPreferredSize(new Dimension(360, 100));
		JScrollPane scrollPanea = new JScrollPane(jtaaa);
		JScrollPane scrollPaneb = new JScrollPane(jtabb);
		jtabb.setForeground(Color.red);
		jbaa = new JButton("����");		
		jbbb = new JButton("���");		
		jbbc = new JButton("",iic2);
		jbc.setMnemonic(KeyEvent.VK_F);
		jtaaa.setFont(new Font("Serif",Font.BOLD,14));
		jtabb.setFont(new Font("Serif",Font.BOLD,14));
	    jbaa.setForeground(Color.BLACK);
		jbbb.setForeground(Color.BLACK);
		jbbc.setForeground(Color.BLACK);
		jfaa.add(jpaa,BorderLayout.NORTH);
		jfaa.add(jpp,BorderLayout.CENTER);
		jfaa.add(jpll,BorderLayout.SOUTH);
		jfaa.setIconImage(Toolkit.getDefaultToolkit().createImage(qqurl));
		jpaa.add(scrollPanea);
		jpp.add(scrollPaneb);
		jpll.add(jbaa);
		jpll.add(jbbc);
		jpll.add(jbbb);
		jf.setBackground(new Color(100, 253, 98));
		jpaa.setBackground(new Color(100, 253, 98));		
		jpp.setBackground(new Color(100, 253, 98));		 
		jpll.setBackground(new Color(100, 253, 98));		 
		jfaa.setSize(380, 400);
		jfaa.setLocation(500, 150);
		jfaa.setResizable(false);
		jfaa.setVisible(false);	
		 	   
		jbbb.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				jtabb.setText("");
			}
			
		});
		
//		��ʼ�������û��б�
		jfb = new JFrame();
		jpan = new JPanel();
		dlm = new DefaultListModel();
		jli = new JList(dlm);
		jb = new JButton(">>>Ⱥ��ģʽ");
		jli.setForeground(Color.BLUE);
		jb.setSize(15, 20);
		jb.setForeground(Color.BLUE);
		jfb.add(jpan);
		jpan.setLayout(new BorderLayout());
		jpan.add(jli, BorderLayout.CENTER);
		jpan.add(jb, BorderLayout.SOUTH);
		jpan.add(jli);
		jfb.setIconImage(Toolkit.getDefaultToolkit().createImage(qqurl));
		jfb.setResizable(false);
		jfb.setLocation(500, 200);
		jfb.setSize(200, 450);
		jfb.setVisible(false);
		
	}
}

最近下载更多
微信网友_7004855557083136  LV1 2024年5月22日
cksndh  LV4 2023年8月16日
fuyouou  LV5 2023年6月29日
yuanchuang  LV22 2023年2月14日
liys1234  LV9 2022年6月21日
微信网友_6003487859068928  LV5 2022年6月15日
微信网友_5989987974549504  LV5 2022年6月5日
17岁的孩子想糖吃  LV7 2021年12月31日
111111255  LV2 2021年12月24日
Aoifee  LV4 2021年11月10日
最近浏览更多
微信网友_7004855557083136  LV1 2024年5月22日
goccgoccgocc  LV4 2024年5月9日
krispeng  LV14 2024年4月15日
陈小灏  LV18 2023年12月26日
luamweise 2023年10月18日
暂无贡献等级
wertttak  LV1 2023年9月26日
小新Coding  LV9 2023年9月7日
cksndh  LV4 2023年8月16日
fuyouou  LV5 2023年6月29日
2017143155  LV12 2023年6月24日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友