SHOW:
|
|
- or go back to the newest paste.
1 | class AscoltatoreMouse extends MouseAdapter{ | |
2 | public void mousePressed(MouseEvent e){ | |
3 | - | for(int i=0;i<numeri.length;i++){ |
3 | + | JButton bottoneMagico; |
4 | - | //if(e.getComponent() instanceof JButton) |
4 | + | if(e.getComponent() instanceof JButton) { |
5 | - | if(e.getSource() == numeri[i]) |
5 | + | bottoneMagico = (JButton)e.getComponent(); |
6 | - | casellaDiCalcolo.setText(numeri[i].getText()); |
6 | + | casellaDiCalcolo.setText(bottoneMagico.getText()); |
7 | - | if(i<operatori.length) |
7 | + | }//if |
8 | - | if(e.getSource() == operatori[i]) |
8 | + | |
9 | - | casellaDiCalcolo.setText(operatori[i].getText()); |
9 | + |