Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-17-2008, 10:28 PM
Member
 
Join Date: Jan 2008
Posts: 7
RLRExtra is on a distinguished road
Displaying text in a JTextField after pressing a button
Having a problem with getting text to display in a text field after a button is pressed.

I've tried useing the getText and setText but I don't think I've done it properly.

This is what I'm useing:

JTextField showHumanScores = new JTextField(15);

String fieldHumanScores = showHumanScores.getText();

fieldHumanScores.setText((humanHand[0]));

Is this correct and my problem lies somewhere else?

Anything to do with humanHand being an int?

Last edited by RLRExtra : 01-17-2008 at 10:35 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-17-2008, 10:34 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Hi RLRExtra

Try this:
Code:
showHumanScores.setText(humanHand[0]);
Quote:
Originally Posted by RLRExtra
Code:
fieldHumanScores.setText((humanHand[0]));
I don't think that the String class has a setText() method since fieldHumanScores is an instance of String.

Hope this helped.
__________________
If your ship has not come in yet then build a lighthouse.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-17-2008, 10:43 PM
Member
 
Join Date: Jan 2008
Posts: 7
RLRExtra is on a distinguished road
Nope, doesn't work!

When I try compile it, I get:

in javax.swing.text.JTextComponent cannot be applied to (int)
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-17-2008, 10:46 PM
Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 18
jimm1 has a little shameless behaviour in the past
Is humanHand an int array?
If so,

try...

showHumanScores.setText(Integer.toString(humanHand[0]));

Last edited by jimm1 : 01-17-2008 at 10:50 PM.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-17-2008, 10:56 PM
Member
 
Join Date: Jan 2008
Posts: 7
RLRExtra is on a distinguished road
Nice one! It works now, thank you!
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-17-2008, 11:01 PM
Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 18
jimm1 has a little shameless behaviour in the past
Glad to be of assistance.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to focus to another JTextfield? birdofprey AWT / Swing 2 04-09-2008 03:08 PM
Displaying data into text area abhiN New To Java 1 01-22-2008 12:30 PM
Displaying text box on MIDlet form Java Tip Java Tips 0 11-22-2007 12:06 PM
Java Next Button for displaying next row susan Enterprise JavaBeans 1 08-07-2007 06:16 AM
help with JTextfield gary New To Java 4 07-11-2007 03:58 PM


All times are GMT +3. The time now is 01:31 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org