Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Trying to display text from JTextField on a JTextArea

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.) Here is my code:


2.) Here is my Error Message:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Gui.actionPerformed(Gui.java:265)


I can't figure out why line 265[System.out.println(txtbox.getText())] doesnt work here.  Ive tried some variations of this and still can't seem to get anything to work other than displaying a message on the console, but I can't get the txt from txtbox and display it in the console. please help!
 
Saloon Keeper
Posts: 6042
58
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've declared a variable txtbox twice, once as a member variable and once as a local variable.
 
dobbeykins dd
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Carey Brown wrote:You've declared a variable txtbox twice, once as a member variable and once as a local variable.



Thanks for your help and for getting back to me so quickly Carey.  That fixed the problem.  Cheers!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!