File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "text field" Watch "text field" New topic

text field


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);
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
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).
GeeCON Prague 2014
subject: text field