Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my code

the build
C#
UserNameTextBox = new JTextField();
        UserNameTextBox.setHorizontalAlignment(SwingConstants.CENTER);
        UserNameTextBox.setBounds(562, 326, 119, 20);
        contentPane.add(UserNameTextBox);
        UserNameTextBox.setColumns(10);


the code
Java
	URL url2 = new URL("http://mcskinsearch.com/img/cache/pic/z3nox.png");
		image2 = new ImageIcon(ImageIO.read(url2));
		image2 = new ImageIcon(image2.getImage().getScaledInstance(297, 297, BufferedImage.SCALE_SMOOTH));
		FrontImage = new JLabel(image2);
		FrontImage.setHorizontalAlignment(SwingConstants.LEFT);
		FrontImage.setVerticalAlignment(SwingConstants.TOP);
		FrontImage.setBounds(10, 11, 151, 297);
		contentPane.add(FrontImage);

UserNameTextBox.getDocument().addDocumentListener(new DocumentListener() {
     public void removeUpdate(DocumentEvent e) {
        // TODO add code!

     }

     public void insertUpdate(DocumentEvent e) {
        // TODO add code!

     }

     public void changedUpdate(DocumentEvent e) {
        // TODO add code!
	URL url3 = new URL("http://mcskinsearch.com/img/cache/pic/z3nox.png");
		image3 = new ImageIcon(ImageIO.read(url3)); 
     }
  });


my error is located
C#
public void changedUpdate(DocumentEvent e) {
    // TODO add code!
URL url3 = new URL("http://mcskinsearch.com/img/cache/pic/" + UserNameTextBox.text  +   ".png");
    image3 = new ImageIcon(ImageIO.read(url3));
 }


the problem is, I cannot acess and change the varible of the url so whenthe user types in like a name the url will change so then the image it is showing will change, cna some one please help, why wont it let me change it?
Posted
Updated 19-Jul-13 18:28pm
v2
Comments
Shubhashish_Mandal 19-Jul-13 7:11am    
its not so clear whether you are not access the textFiled value or the you have got the value but unable to display the image.
[no name] 19-Jul-13 17:12pm    
I am in able to access the value
AlphaDeltaTheta 20-Jul-13 0:27am    
You are missing a setter call to the JLabel.
FrontImage.setIcon(image3);
and remember to enclose it in a try-catch. Else if you get an HTTP 404, the code will blow.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900