![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Jun 2005
Location: London, England
Posts: 24
Rep Power: 0
![]() |
Need some help with MouseListeners and array
I'm making a spreadsheet program in java but i am stuck on getting my mouselisteners to behave the way i want them to.
On mousePressed the clicked on cell in the array defaulttablecellrenderer should change colour, like in excel or any spreadsheet program. but i've tried numerous methods but still can't get it to work. Here is my code for the mouselistener part:
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
for (int i = 0; i<cell.length;i++){
if (cell[i] == e.getSource()){
cell[i].setBackground(Color.BLUE);
System.out.println("worked");
}
else{
System.out.println("no");
}
}
}The system does print out "worked" so i guess my listeners are working, but i just can't seem to get the background of that cell clicked upon to change. Maybe i am overlooking something very simple or maybe not. Any ideas?
__________________
biggest NOOB ever :P |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|