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:
  #16  
Old December 4th, 2012, 02:17 PM
MrHodd MrHodd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 14 MrHodd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 52 sec
Reputation Power: 0
How would I print out the value of Gooey() or of a JTextArea?

Reply With Quote
  #17  
Old December 4th, 2012, 02:32 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 53 m 34 sec
Reputation Power: 345
I'm not sure why you're interested in those items. Neither of them are variables.
The NPE is on line 65. You need to look at the variables on line 65 and find which one has a null value. Print it with something like this:
Code:
System.out.println("an ID "+ <theVarNameHere>);

Last edited by NormR : December 4th, 2012 at 02:35 PM.

Reply With Quote
  #18  
Old December 4th, 2012, 02:39 PM
MrHodd MrHodd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 14 MrHodd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 52 sec
Reputation Power: 0
There really arent any variables, line 65 points to a method that calls setText but I did find that when I am trying to reference the instance of my Gooey that it is null. What is the proper way to reference an instance of another class? I think that is where my problem lies.

Reply With Quote
  #19  
Old December 4th, 2012, 02:48 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 53 m 34 sec
Reputation Power: 345
Quote:
There really arent any variables

Post the contents of line 65 if you need help finding the variable(s) used on that line.

Quote:
proper way to reference an instance of another class

By getting the address of the instance into a variable. The first reference will be returned by a new statement.

Reply With Quote
  #20  
Old December 4th, 2012, 02:58 PM
MrHodd MrHodd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 14 MrHodd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 52 sec
Reputation Power: 0
If you look at my previous post, line 65 is:

Code:
testClass.setEventText();



Which is:
Code:
public void setEventText()
	{
		textArea.setText("test");
	}


testClass is null here. So I think I need to figure out how to properly reference the instance of testClass(which is instantiated in another class).

Reply With Quote
  #21  
Old December 4th, 2012, 03:11 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 53 m 34 sec
Reputation Power: 345
the variable: testClass needs to have the address of an instance of the class: HelloWorldApp2. If an instance of the class already exists, then a reference tot the class should be passed in an arg to the class where its value is needed and saved there in a class variable.
If there isn't an instance of the class, then use a new statement to create the instance and get its address.

Last edited by NormR : December 4th, 2012 at 03:16 PM.

Reply With Quote
  #22  
Old December 4th, 2012, 03:29 PM
MrHodd MrHodd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 14 MrHodd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 52 sec
Reputation Power: 0
Could you show me an example. I understand the logic but I'm having trouble with the syntax(or doing it properly I suppose). I can not create a new instance so I need to reference the instance that was created in the other class, but I'm unsure of how to do this. How would you reference the instance testClass from another class?

Reply With Quote
  #23  
Old December 4th, 2012, 03:34 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 53 m 34 sec
Reputation Power: 345
Quote:
reference the instance that was created in the other class

Use the this variable to refer to the current class that the code is executing in.
Pass a reference:
Code:
 refToAnotherClass.passRef(this);  // pass a reference to this instance

Reply With Quote
  #24  
Old December 4th, 2012, 03:43 PM
MrHodd MrHodd is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 14 MrHodd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 52 sec
Reputation Power: 0
I didn't really understand the example but after hours of testing I finally am able to get things working correctly. Thanks for the help! (btw it was the null reference to my Gooey instance that was throwing the error )

Reply With Quote
  #25  
Old December 4th, 2012, 03:56 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 2,955 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 53 m 34 sec
Reputation Power: 345
Glad you got it working.
Quote:
it was the null reference to my Gooey instance that was throwing the error

Strange, I don't see any variables that hold a reference to an instance of the Gooey class.

Last edited by NormR : December 4th, 2012 at 03:58 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Updating JTextArea using Swing Timers

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