I'm having some trouble using getClientproperty() to get a string value
btw, im using java 1.4.2, so no autoboxing

I know how to get int values, and here is an example, which works perfect in my program,

cx = ((Integer) btn.getClientProperty ("cx")).intValue ();

but when i try to get a string value, it wont work

type = ((String) btn.getClientProperty ("type")).StringValue ();

I get error which says
No method named "StringValue" was found in type "java.lang.String".

what am i doing wrong?

Recommended Answers

All 5 Replies

No method named "StringValue" was found in type "java.lang.String".

The compiler can not find a method called StringValue for the String class. Where did you see that defined as a method?

What is the type of the value you stored with the key of "type"?

i dont, i was just trying stuff out, i was trying to get the object to a string, idk, do you know what the object type of a string is, becouse i cant find it

have you tried the valueOf(...) method? the String class doesn't have a StringValue() method, which is exactly what your error is telling you.

a String is a String.. what exactly do you mean by: what the objecttype of a String is?

You just need to cast the Object that's returned. String isn't a primitive so there's no boxing involved
String s = (String) btn.getClientProperty ("myString");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.