我有一组jbuttons。我想将Home_MouseDown
过程添加到jbutton的mousePressed事件中。下面是我创建的JButton数组。
代码:
Jbutton[][] home = new JButton[8][8];
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
home[j][i] = new JButton();
this.add(home[j][i]);
}
}
答案 0 :(得分:1)
Home[j][i].addActionListener(new ActionListener(){
@Override
ActionPerformed(ActionEvent evt){
//w.e function u wanna add here on mouse click
}
});