62,614
社区成员
发帖
与我相关
我的任务
分享
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);
}
}
}
label=new JLabel(new ImageIcon("image/face/"+x+".gif"));
label.setBorder(BorderFactory.createLineBorder(Color.BLUE,2));