Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
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
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:53 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC