Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 30th, 2012, 03:11 PM
petedshow petedshow is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 5 petedshow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 33 m 10 sec
Reputation Power: 0
GetRed() returns to an error

I'm working with JLabels and Colors but it seems like I failed somewhere with the coding.
In my application every necessary class is imported and extended, implented in the class.
Here's the bad part of the code which causes the error:

...
public void mouseEntered(MouseEvent e) {
for (int i = 0; i < m.length; i++) {
if(e.getSource() == m[i]) {
Color current = Color.getColor(mLabel[i]);
rHover = current.getRed();
...
}
}
}
...

variables declared as:
m[] is a JLabel array
mLabel[] is a String array
rHover is an integer.

I guess I've told every necessary information, if not, please tell me. I've tried doing this in different ways, but none of them succeeded. This current code can be compiled, so there is no syntax error.
What I want, in short, is a really simple hover effect for any colored JLabel. As told before, m[] is the JLabel array and mLabel[] array contains the Texts for each JLabel. I wanted to get the color of these Strings and change them on MouseEnter.

What am I doing wrong? Please help me.

Reply With Quote
  #2  
Old October 31st, 2012, 02:45 PM
stdunbar's Avatar
stdunbar stdunbar is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: May 2004
Location: Superior, CO, USA
Posts: 2,398 stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 18 h 14 m 16 sec
Reputation Power: 1660
Send a message via Yahoo to stdunbar Send a message via Google Talk to stdunbar
What is the error? Does your computer catch on fire? Does the program not run? Is there a hole opened in time and space?

A SSCCE showing the problem - whatever it is - would speed up our ability to help you.
__________________
Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums.

Reply With Quote
  #3  
Old October 31st, 2012, 03:58 PM
petedshow petedshow is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 5 petedshow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 33 m 10 sec
Reputation Power: 0
The code is pretty long, but I'll try to make an SSCCE later.
What really happens is, as you said, my computer catches on fire... it is really irritating.

For real: the application crashes as soon as it should do that part of the code which I have mentioned. If I delete the getRed() line, the app just runs perfectly.

Reply With Quote
  #4  
Old October 31st, 2012, 04:45 PM
stdunbar's Avatar
stdunbar stdunbar is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: May 2004
Location: Superior, CO, USA
Posts: 2,398 stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level)stdunbar User rank is General 10th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 18 h 14 m 16 sec
Reputation Power: 1660
Send a message via Yahoo to stdunbar Send a message via Google Talk to stdunbar
What does crash mean here? Does the program generate a big stack trace and a file that has a name that starts with hs_err? Does it throw any kind of error?

Additionally, what O/S are you on and what version of Java are you running?

Reply With Quote
  #5  
Old October 31st, 2012, 06:23 PM
petedshow petedshow is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 5 petedshow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 33 m 10 sec
Reputation Power: 0
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at GuessWindow.mouseEntered(GuessWindow.java:423)

Those are the first 2 lines. The rest tells mostly like
"at java.awt. ..." and so.
Like 30-40 lines.

I have 64 bit Win 7 and the latest java installed.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > GetRed() returns to an error

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap