⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 face_choser.java

📁 IO流的项目好
💻 JAVA
字号:
package myQQ;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class Face_Choser extends JFrame implements ActionListener
{
	Adom ad = new Adom();
	QQPhoto  QQp;
	//背景面板
	Image imBackground = Toolkit.getDefaultToolkit().getImage("QQ/skin/bg1.png");
	MyPane mp = new MyPane(imBackground,640,480);
	//主面板区
	//球星--------------------------------
	ImageIcon []imQiuXing = new ImageIcon[6];
	JButton []jbQiuXing = new JButton[6];
	JPanel jpQiu[] = new JPanel[6];
	JPanel jpQiuXing = new JPanel(new GridLayout(1,6));
	//男
	ImageIcon []imMan = new ImageIcon[26];
	JButton []jbMan = new JButton[26];
	JPanel jpM[] = new JPanel[26];
	JPanel jpMan = new JPanel(new GridLayout(6,6));
	//女
	ImageIcon []imWoman = new ImageIcon[27];
	JButton []jbWoman = new JButton[27];
	JPanel []jpWm = new JPanel[27];
	JPanel jpWoman = new JPanel(new GridLayout(6,6));
	//动物
	ImageIcon []imDongWu = new ImageIcon[33];
	JButton []jbDongWu = new JButton[33];
	JPanel []jpDw = new JPanel[33];
	JPanel jpDongWu = new JPanel(new GridLayout(6,6));
	//QQ堂
	ImageIcon []imTang = new ImageIcon[8];
	JButton []jbTang = new JButton[8];
	JPanel []jpT = new JPanel[8];
	JPanel jpTang = new JPanel(new GridLayout(2,6)); 
	//可爱
	ImageIcon []imKeAi = new ImageIcon[15];
	JButton []jbKeAi = new JButton[15];
	JPanel []jpKA = new JPanel[15];
	JPanel jpKeAi = new JPanel(new GridLayout(3,6));
	JPanel jpMain = new JPanel(new GridLayout(6,1,0,0));
	JScrollPane jsp = new JScrollPane(jpMain);
	JPanel jp1 = new JPanel();
	MyPane jp2 = new MyPane(imBackground,500,450);
	//右侧面板
	JPanel jpRight = new JPanel();
	JLabel jl1 = new JLabel("预览");
	JLabel jlFace = new JLabel(new ImageIcon("QQ/head/Qiu/1.gif"));
	//底部按扭面板
	MyPane mpBottom = new MyPane(imBackground,500,100);
	QQButton jbQueDing = new QQButton("QQ/skin/default/s0","确定");
	QQButton jbQuXiao = new QQButton("QQ/skin/default/s0","取消");
	//顶部标签
	JLabel jlTiShi = new JLabel("请选择头像",new ImageIcon("QQ/head/6.gif"),JLabel.LEFT);
	
	public Face_Choser(QQPhoto QQp)
	{
		super("选择头像");
		this.setIconImage(Adom.icon);
		this.QQp = QQp;
		this.setSize(500,450);
		Container c = this.getContentPane();
	//	c.setLayout(null);
		this.setLocation(ad.setCenter(550,450));
		this.setResizable(false);
		this.setBackground(Color.white);
		//---------------------------------------------------------------------
		mpBottom.setLayout(new FlowLayout(FlowLayout.RIGHT,20,20));
		mpBottom.add(jbQueDing);	mpBottom.add(jbQuXiao);
		//----------------------------------------------------------------------
		jp2.setLayout(null);
		jp2.setBackground(Color.white);
		jpRight.setLayout(null);
		jl1.setBounds(5,0,40,20);		
		jlFace.setBounds(5,22,40,40);
		jlFace.setBorder(BorderFactory.createEtchedBorder());
		jpRight.setBackground(Color.white);
		jpRight.add(jl1,null);		jpRight.add(jlFace,null);
		//构件主面板
		jp1.setLayout(null);
		//球星头像
		for (int i = 0; i<jbQiuXing.length; i++)
		{
			imQiuXing[i] = new ImageIcon("QQ/head/Qiu/"+(i+1)+".gif");
			jbQiuXing[i] = new JButton(imQiuXing[i]);
			jbQiuXing[i].addActionListener(this);
			jpQiu [i] = new JPanel();
			jbQiuXing[i].setOpaque(false);jbQiuXing[i].setBorder(null);
			jpQiu[i].setBackground(Color.white);
			jpQiu[i].add(jbQiuXing[i]);
			jpQiuXing.add(jpQiu[i]);
		}
		jpQiuXing.setBackground(Color.white);
		jpQiuXing.setBorder(BorderFactory.createTitledBorder("球星头像"));
		//男--头像
		for (int i = 0; i<jbMan.length; i++)
		{
			imMan[i] = new ImageIcon("QQ/head/Man/"+(i+1)+"-1.jpg");
			jbMan[i] = new JButton(imMan[i]);
			jbMan[i].addActionListener(this);
			jpM[i] = new JPanel();
			jbMan[i].setOpaque(false);jbMan[i].setBorder(null);
			jpM[i].setBackground(Color.white);
			jpM[i].add(jbMan[i]);
			jpMan.add(jpM[i]);
		}
		jpMan.setBackground(Color.white);
		jpMan.setBorder(BorderFactory.createTitledBorder("男士头像"));
		jpMain.add(jpMan);
		//女
		for (int i = 0; i<jbWoman.length; i++)
		{
			imWoman[i] = new ImageIcon("QQ/head/Woman/"+(i+1)+"-1.jpg");
			jbWoman[i] = new JButton(imWoman[i]);
			jbWoman[i].addActionListener(this);
			jpWm[i] = new JPanel();
			jbWoman[i].setOpaque(false);jbWoman[i].setBorder(null);
			jpWm[i].setBackground(Color.white);
			jpWm[i].add(jbWoman[i]);
			jpWoman.add(jpWm[i]);
		}
		jpWoman.setBackground(Color.white);
		jpWoman.setBorder(BorderFactory.createTitledBorder("女士头像"));
		jpMain.add(jpWoman);
		//宠物
		for (int i = 0; i<jbDongWu.length; i++)
		{
			imDongWu[i] = new ImageIcon("QQ/head/An/"+(i+1)+".png");
			jbDongWu[i] = new JButton(imDongWu[i]);
			jbDongWu[i].addActionListener(this);
			jpDw[i] = new JPanel();
			jbDongWu[i].setBorder(null);	jbDongWu[i].setOpaque(false);
			jpDw[i].setBackground(Color.white);
			jpDw[i].add(jbDongWu[i]);
			jpDongWu.add(jpDw[i]);
		}
		jpDongWu.setBackground(Color.white);
		jpDongWu.setBorder(BorderFactory.createTitledBorder("宠物头像"));
		jpMain.add(jpDongWu);
		//QQ堂
		for (int i = 0; i<jbTang.length; i++)
		{
			imTang[i] = new ImageIcon("QQ/head/Tang/"+(i+1)+".png");
			jbTang[i] = new JButton(imTang[i]);
			jbTang[i].addActionListener(this);
			jpT[i] = new JPanel();
			jbTang[i].setBorder(null);	jbTang[i].setOpaque(false);
			jpT[i].setBackground(Color.white);
			jpT[i].add(jbTang[i]);
			jpTang.add(jpT[i]);
		}
		jpTang.setBackground(Color.white);
		jpTang.setBorder(BorderFactory.createTitledBorder("QQ堂头像"));
		jpMain.add(jpTang);
		//可爱
		for (int i = 0; i<jbKeAi.length; i++)
		{
			imKeAi[i] = new ImageIcon("QQ/head/KeAi/"+(i+1)+".png");
			jbKeAi[i] = new JButton(imKeAi[i]);
			jbKeAi[i].addActionListener(this);
			jpKA[i] = new JPanel();
			jbKeAi[i].setBorder(null);	jbKeAi[i].setOpaque(false);
			jpKA[i].setBackground(Color.white);
			jpKA[i].add(jbKeAi[i]);
			jpKeAi.add(jpKA[i]); 
		}
		jpKeAi.setBackground(Color.white);
		jpKeAi.setBorder(BorderFactory.createTitledBorder("咔哇依头像"));;
		jpMain.add(jpKeAi);	jpMain.add(jpQiuXing);	jpMain.setBackground(Color.white);
		jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS );
		jsp.setBounds(0,0,325,310);		jp1.add(jsp);
		//-----------------------------------------------------------------------
		jbQueDing.addActionListener(this);	jbQuXiao.addActionListener(this);
		//----------------------------------------------------------------------
		jp1.setBounds(60,50,325,310);	jpRight.setBounds(385,50,55,310);
		jlTiShi.setBounds(60,25,375,20);
		jp2.add(jlTiShi,null);
		jp2.add(jp1,null);	
		jp2.add(jpRight,null);
		c.add(jp2);	c.add(mpBottom,BorderLayout.SOUTH);
	//	this.show();
	}
	
	public void actionPerformed(ActionEvent e)
	{
			for (int i = 0; i<jbDongWu.length; i++)
			{
				if(e.getSource().equals(jbDongWu[i]))
				{
					jlFace.setIcon(jbDongWu[i].getIcon());	
				}
				
			}
			for (int i = 0; i<jbTang.length; i++)
			{
				if(e.getSource().equals(jbTang[i]))
				{
					jlFace.setIcon(jbTang[i].getIcon());	
				}
				
			}
			for (int i = 0; i<jbMan.length; i++)
			{
				if(e.getSource().equals(jbMan[i]))
				{
					jlFace.setIcon(jbMan[i].getIcon());	
				}
				
			}
			for (int i = 0; i<jbWoman.length; i++)
			{
				if(e.getSource().equals(jbWoman[i]))
				{
					jlFace.setIcon(jbWoman[i].getIcon());	
				}
				
			}
			for (int i = 0; i<jbKeAi.length; i++)
			{
				if(e.getSource().equals(jbKeAi[i]))
				{
					jlFace.setIcon(jbKeAi[i].getIcon());
				}
					
			}
			for (int i = 0; i<jbQiuXing.length; i++)
			{
				if(e.getSource().equals(jbQiuXing[i]))
				{
					jlFace.setIcon(jbQiuXing[i].getIcon());	
				}
				
			}
			if(e.getSource().equals(jbQueDing))
			{
				QQp.jlPhoto.setIcon(jlFace.getIcon());
				this.show(false);
			}
			if(e.getSource().equals(jbQuXiao))
			{
				this.show(false);
			}
	}
		
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -