Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GUI Code Problem  RSS feed

 
Jason Sgalla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am new to Java and I am having trouble coding a simple GUI program to work for me. I am trying to display the contents of an array in a JTextField but it will not recognize the array. Here is my code:



Also I can't get my panels to work for me consistently. Any input to help me figure out what I am doing wrong would be appreciated. Also any input as to fix my method for creating my components would be helpful as well.

Thanks
Jason
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello and welcome to JavaRanch!

You'll find that for learning Java one of your best resources is the API and the Sun (Oracle) Java tutorials, and in this regard learning Swing is no different.

For one, you're trying to use an array before it has been declared, and for another you're trying to add text to a JTextField by passing two String parameters separated by a comma, and the API will show you that there is no such method like that, that you'll need to add just one String to the JTextField.

Best of luck!
 
Jason Sgalla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pete thanks for the help! I didn't realize that I still had my "Hello" before the array in the code. That was just there for me to see that the textfield was actually working - but I didn't know that I couldn't pass two things into it by using the comma so that is nice to know. Also I moved the array up and it worked out like you said it would.

Thanks for the help! I have some room to work now.
Jason
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(On the meta side, note that the highlighting you believed would happen in your post didn't--it's much cleaner to leave it out and reference the line numbers in the code block.)
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason,
Welcome to the Ranch.

We have a forum dedicated for GUI related questions. I will move this thread over there for you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!