aspose file tools*
The moose likes Beginning Java and the fly likes text field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "text field" Watch "text field" New topic
Author

text field

ksnewbie
Greenhorn

Joined: Feb 17, 2002
Posts: 1
I am really green at programming in Java, I hope someone can help.
My objective is to create a sort of photo album, to insert a name of a image in a text field and the image then appears.
I was going about it like this:
public void paint(Graphics g) {
if (imageField = "picture1")
g.drawImage(image1, 20,20,100, 100, this);
else
g.drawImage(image2, 20,20,100, 100, this);
but I get an error for incompatable types.
Any suggestions??
Should I be placing it in an actionPerformed method?
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi,
Your programming error is in using = instead of == . Your if statement is trying to perform an assignment and you probably just want a compare.
Your second is that == won't work as you expect for a String. You should use the equals method to compare one string to another.
NOTE: Your name is not a valid one here at the ranch. Please read the naming policy and re-register with a professional name (i.e., first name + space + last name).
Regards,
Manfred.
 
Consider Paul's rocket mass heater.
 
subject: text field