need help in uploading images in swing program!!!
Hi guys!
i am quite a noob in java... don't worry, i got the basics already...
uhm... I just want to ask this question:
'How do you make a program not terminate imediately once you clicked a button?...
Grrr.. let me try to explain it this way....
uhmm... I'm working on a simple project that says, "My Profile Manager"..
This program has fields for the user's name, age, etc, something like that...
I'm just a noob so, the project only works one-way... meaning, the profile of certain people are built-in within the program...
This is what happens, when a person enters his name, age, etc,... His picture will show up beside the textfields... (I got that already)...
This is simple but my problem is, once I clicked the button, for the first time, it works.... but when i try to type another name, the picture doesn't change... I know I'm missing something here... please help????:confused:
ok.. just focus on the colored lines...
Code:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){
String name = nameField.getText();
String age = ageField.getText();
if(name == "John"){
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/swingPack/joham.jpg")));
}else if(name == "Smiley"){
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/swingPack/smiley.jpg")));
}
}
//[COLOR="DarkGreen"]-> the problem here is, when i type a name for the first time, a new photo will show up... but when I type a new name which supposedly corresponds to a different photo, the previous photo that showed up doesn't change...[/COLOR]
this is my code under my Button's action...
the button is my problem...
sorry guys... I can't explain it clearly... but what i am trying to say is that, the button works only once... how can i make it work again and again and again??