Using changelistener with JSlider and TextFields

I am currently trying to set a textfield with a value received from a JSlider. Basically whatever value is set on the slider bar I need it to populate a related textfield. I am currently using a ChangeListener to set the textfield. My code looks like this:

Change Listener cListener = new ChangeListener()

{

public void stateChanged(ChangeEvent event)

{

JSlider src = (JSlider) event.getSource();

if(!src.getValueIsAdjusting())

{

int cloudCover = sldCover.getValue();

String str = Integer.toString(cloudCover);

txtCloud.setText(str);

}

}

};

This method does not work with the textfield, but it works just fine with a label. Is there another method to achieving this using a textfield? Should I be doing something else?

[809 byte] By [toyar2000a] at [2007-10-3 4:18:54]
# 1

This is your fifth question. Not once have you bothered to reply to a posting to mention whether the suggestions given were helpfull or not. You mention I was rude once for taking the time to answer one of your questions although you didn't like the wording of my answer. Well, I think its rude not to thank people for the help given.

Not only don't you respond to your old posting, you don't even listen to the advice given.

a) your posted code is still not formatted

b) your posted code is still not executable

> This method does not work with the textfield, but it works just fine with a label

> txtCloud.setText(str); (I assume this is the method you are referring to

Yes, it does. You just have a bug in your program and we can't help you since you didn't follow the advice given above.

I'm sure I'm in for another lecture on how to answer questions correctly...

camickra at 2007-7-14 22:20:39 > top of Java-index,Desktop,Core GUI APIs...
# 2

My reasons for using this service is to receive help and not to offend anyone or to be offended. I have responded to posts that others have made regarding advice. No I didn't reply to all of them because I have not put all the advice to work yet. I do appreciate any help given.

As far as this issue is concerned, I found the answer myself, but thank you for looking at my post.

I am not exactly sure what you mean by my code not being formatted.

toyar2000a at 2007-7-14 22:20:39 > top of Java-index,Desktop,Core GUI APIs...
# 3

> No I didn't reply to all of them

You haven't replied to any of them

> because I have not put all the advice to work yet

some questions are a month old.

> I do appreciate any help given.

Then reply to each posting in a timely manner stating so.

> I am not exactly sure what you mean by my code not being formatted.

Have you read your other postings? When other people post code it is properly indented, with keywords highlighted.

You have been given instructions on how to do this. Again read your old postings.

camickra at 2007-7-14 22:20:39 > top of Java-index,Desktop,Core GUI APIs...