java MouseListener
for(i=0;i<81;i++){rrecordJLabel[i]=newJLabel(newImageIcon("recordicon0.png"));rrecord...
for(i = 0; i<81;i++){
rrecordJLabel[i] = new JLabel(new ImageIcon("recordicon0.png"));
rrecordJLabel[i].setBounds(70,79 + 21*(i%9),184,21);
rrecordJLabel[i].addMouseListener(new MouseListener(.......){}
}
for(i = 0; i<81;i++){
rrecordJLabel[i] = new JLabel(new ImageIcon("recordicon0.png"));
rrecordJLabel[i].setBounds(70,79 + 21*(i%9),184,21);
rrecordJLabel[i].addMouseListener(new MouseListener(){
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
rrecordJLabel[i].setIcon(new ImageIcon("recordicon0.png"));//!!!!!!!!
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}});
}
想通过鼠标事件对每个JLabel进行监听,
函数运行的时候!!!!!!!的地方i总是默认为81 怎么修改才好呢???
解决加分50
开始的那个:
for(i = 0; i<81;i++){
rrecordJLabel[i] = new JLabel(new ImageIcon("recordicon0.png"));
rrecordJLabel[i].setBounds(70,79 + 21*(i%9),184,21);
rrecordJLabel[i].addMouseListener(new MouseListener(.......){}
} 不要看 是多余的。。。。。 展开
rrecordJLabel[i] = new JLabel(new ImageIcon("recordicon0.png"));
rrecordJLabel[i].setBounds(70,79 + 21*(i%9),184,21);
rrecordJLabel[i].addMouseListener(new MouseListener(.......){}
}
for(i = 0; i<81;i++){
rrecordJLabel[i] = new JLabel(new ImageIcon("recordicon0.png"));
rrecordJLabel[i].setBounds(70,79 + 21*(i%9),184,21);
rrecordJLabel[i].addMouseListener(new MouseListener(){
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
rrecordJLabel[i].setIcon(new ImageIcon("recordicon0.png"));//!!!!!!!!
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}});
}
想通过鼠标事件对每个JLabel进行监听,
函数运行的时候!!!!!!!的地方i总是默认为81 怎么修改才好呢???
解决加分50
开始的那个:
for(i = 0; i<81;i++){
rrecordJLabel[i] = new JLabel(new ImageIcon("recordicon0.png"));
rrecordJLabel[i].setBounds(70,79 + 21*(i%9),184,21);
rrecordJLabel[i].addMouseListener(new MouseListener(.......){}
} 不要看 是多余的。。。。。 展开
3个回答
展开全部
修改
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
JLabel lab=(JLabel) e.getSource();
if(lab.equals(rrecordJLabel[0])){
//写你的代码
}
}});
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
JLabel lab=(JLabel) e.getSource();
if(lab.equals(rrecordJLabel[0])){
//写你的代码
}
}});
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询