📄 qqphoto.java
字号:
//头像选择
package myQQ;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class QQPhoto extends JPanel implements ActionListener
{
JLabel jlPhoto;
QQButton qb = new QQButton("QQ/skin/default/s2","");
Face_Choser fc;
boolean flag;
//--------------------------------------------------------------------------------
JPopupMenu pMenu = new JPopupMenu();
JMenuItem[] me = new JMenuItem[5];
String[] sme = {"上线","隐身","离开","下线","个人设置"};
ImageIcon[] icme = new ImageIcon[5];
JLabel jlNiCheng;
//--------------------------------------------------------------------------------
public QQPhoto()
{
flag = true;
this.setLayout(null);
this.setOpaque(false);
jlPhoto = new JLabel(new ImageIcon("QQ/head/Tang/1.png"));
jlPhoto.setBounds(10,10,40,40);
qb.setBounds(52,10,12,40);
qb.addActionListener(this);
this.add(jlPhoto,null); this.add(qb,null);
}
public QQPhoto(String sNiCheng ,String sURL,String sId)
{
flag = true;
jlNiCheng = new JLabel(sNiCheng+"("+sId+")");
this.setLayout(null);
this.setOpaque(false);
jlPhoto = new JLabel(new ImageIcon(sURL));
jlPhoto.setBounds(5,10,40,40);
qb.setBounds(45,1,12,40);
jlNiCheng.setBounds(61,5,100,20);
qb.addMouseListener(new mm());
this.add(jlPhoto,null); this.add(qb,null);
this.add(jlNiCheng,null);
for (int i = 0; i<icme.length; i++)
{ //初始化图标
icme[i] = new ImageIcon("QQ/state/m"+i+".png");
}
for (int i = 0; i<me.length; i++)
{
me[i] = new JMenuItem(sme[i]+" ",icme[i]);
pMenu.add(me[i]);
me[i].addActionListener(this);
me[i].setBackground(Color.white);
}
pMenu.setBackground(Color.white);
}
class mm extends MouseAdapter
{
public void mouseReleased(MouseEvent e)
{
if(e.getSource().equals(qb))
{
pMenu.show(e.getComponent(),e.getX(),e.getY());
}
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(qb))
{
if(flag)
{
fc = new Face_Choser(this);
fc.show();
flag = false;
}
else
{
fc.show();
}
}
if(e.getSource().equals(me[4]))
{
if(flag)
{
fc = new Face_Choser(this);
fc.show();
flag = false;
}
else
{
fc.show();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -