Hi guys I have a problem that makes me really confused, I have ‘writeMethod’ which is a type of Method class, ‘dpv’ which is a type of a propertyDescriptor, i retrieved the writeMethod of the object by getWriteMethod(), now my problem is how to set ‘writeMethod’ to write on a property of an object (e.g. JLabel, JButton) here is my code :
if(dpv.getPropertyType().isPrimitive()
|| dpv.getPropertyType().isInstance("Integer") )
{
Method writeMethod = dpv.getWriteMethod();
//setWriteMethod(writeMethod);<---------- Not sure about this part (doesn't work)
System.out.println(writeMethod);
PropertyValue.setEnabled(true);
SetButton.setEnabled(true);
}
else{
PropertyValue.setEnabled(false);
SetButton.setEnabled(false);
}
Thanks for your help guys
To use the method to write the propery, you have to invoke it. Simple properties take a single value – the value of the property, so you invoke the method with a single argument. The following code sets the property on a button to the value 42:
It’s unlikely you have them, but if the property is the seldom-used indexed property type, then you need to use the method like this:
This corresponds to the setter method