Results 1 to 11 of 11
- 01-26-2009, 06:47 AM #1
Member
- Join Date
- Jan 2009
- Posts
- 31
- Rep Power
- 0
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:Last edited by ashton; 01-26-2009 at 06:49 AM.
- 01-26-2009, 06:54 AM #2
- 01-26-2009, 07:04 AM #3
Member
- Join Date
- Jan 2009
- Posts
- 31
- Rep Power
- 0
ok.. just focus on the colored lines...
Java 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...
- 01-26-2009, 07:35 AM #4
If you want to upload the image,do you want to insert into the database?There are many ways.Search for the com.oreilly package for uploading data, it uses MultipartRequest .
- 01-26-2009, 07:36 AM #5
try this
1) use name.equal("...") NOT name == ...
2) why don't you just use this:
jLabel2.setIcon(new ImageIcon("swingPack/smiley.jpg"));USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
- 01-26-2009, 07:51 AM #6
Member
- Join Date
- Jan 2009
- Posts
- 31
- Rep Power
- 0
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??
- 01-26-2009, 09:02 AM #7
Actually button works each time you click it, but label is not changed. You should repaint your label, each time you click the button.
- 01-26-2009, 09:06 AM #8
Member
- Join Date
- Jan 2009
- Posts
- 31
- Rep Power
- 0
ohhhhhhh.....
:eek: gak! gak! gak! gak! I forgot that! tnx pal! I really really thank you for this! :D I almost forgot that... yup... repaint.... tnx a lot!!!!
- 01-26-2009, 09:22 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
ashton, you have started another thread to discuss the same problem. Please stick with one.
- 01-26-2009, 09:42 AM #10
Member
- Join Date
- Jan 2009
- Posts
- 31
- Rep Power
- 0
whoopss...
Sorry ERANGA... won't do this again... i was just afraid that the first one i posted is kinda hard to understand... just tried to explain it in a simpler way...
Next time, i promise..won't make two threads with one topic...
:)
- 01-26-2009, 10:01 AM #11
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Yes lol, it's much better, make sense. Good luck with Java.
Similar Threads
-
Hwlp with "Open", "Save", "Save as..."
By trill in forum New To JavaReplies: 3Last Post: 11-02-2010, 09:26 AM -
How can i save the data Internally(auto save)
By Rama Koti Reddy in forum AWT / SwingReplies: 2Last Post: 11-01-2010, 08:31 PM -
How to save name in Array and Print saved Name
By ppkkyaw in forum New To JavaReplies: 4Last Post: 06-15-2008, 06:44 AM -
How can I save my XML
By FrankyDee in forum XMLReplies: 1Last Post: 03-27-2008, 03:59 PM -
How do I create an Array of Images
By wco5002 in forum New To JavaReplies: 3Last Post: 03-21-2008, 03:45 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks