digiovinazzo commented on issue #5774:
URL: https://github.com/apache/netbeans/issues/5774#issuecomment-1610192551
We ended up fixing the problem creating the `PropertyDescriptor` of the `UI`
property using the constructor that takes `Method`s, not method names. This way
we can get the `PanelUI getUI()` method and not the `ComponentUI getUI()`
method:
```java
try {
Method readMethod = JPanel.class.getDeclaredMethod("getUI"); // NOI18N
Class<?> returnType = readMethod.getReturnType();
if (!returnType.equals(PanelUI.class)) {
throw new RuntimeException("getUI() returns " + returnType + "
instead of PanelUI"); // NOI18N
}
Method writeMethod = JPanel.class.getDeclaredMethod("setUI",
PanelUI.class); // NOI18N
properties[PROPERTY_UI] = new PropertyDescriptor("UI", readMethod,
writeMethod); // NOI18N
} catch (IntrospectionException | NoSuchMethodException | SecurityException
e) {
// XXX: this will not work as it will find the method getUI() returning
ComponentUI, not PanelUI
// see https://github.com/apache/netbeans/issues/5774
properties[PROPERTY_UI] = new PropertyDescriptor("UI",
com.streamsim.commonsgui.SectionPanel.class, "getUI", "setUI"); // NOI18N
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists