做了一个类似QQ表情框,有点问题,请大家看下。。

tx183584 tx183584 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
想在每个表情画一个框,但是有些框不会出现。。
表情包在这里下载:http://u.115.com/file/t95377871e
face.rar
public class   ExpressionDialog extends JDialog{

JLabel label;
int x,y;
final private int WIDTH=30,HEIGHT=30;
public ExpressionDialog(JFrame frame,int xx,int yy)
{

super(frame);

setUndecorated(true);
setLayout(new GridLayout(8,15));
setBounds(xx, yy, 451, 242);
setBackground(Color.blue);
for(x=0;x<120;x++)
{
label=new JLabel(new ImageIcon("image/face/"+x+".gif"));
// System.out.println("image/face/"+x+".gif");

add(label);

}
addWindowListener(new winAction());
addMouseListener(new Action());
}

public void paint(Graphics g)
{
super.paintComponents(g);
g.setColor(new Color(0,0,0));
for(x=0;x<=450;x=x+WIDTH)
for(y=0;y<=230;y=y+HEIGHT)
g.drawRect(x, y, x+HEIGHT, y+WIDTH);

}

class Action extends MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
x=e.getX()/30;
y=e.getY()/30;
//repaint();
JFrame frame = (JFrame) ExpressionDialog.this.getOwner();
}

}
class winAction extends WindowAdapter
{

public void windowDeactivated(WindowEvent e) { //表情框失去焦点时调用
ExpressionDialog.this.setVisible(false);
// ExpressionDialog.this.setVisible(false);
}

}
}
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
tx183584
Java SE 62,620 成员 307,251 内容