View Single Post
Old Apr 26th, 2008, 10:06 AM   #1
gam3r
Newbie
 
Join Date: Jun 2005
Location: London, England
Posts: 24
Rep Power: 0 gam3r is on a distinguished road
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
gam3r is offline   Reply With Quote