You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SwingLibrary keyword "Get List Values" currently only works if the list items are strings, however in some cases the list items are other objects (which in turn can have strings inside). The getListValues() method in ListOperator.java iterates all list items and tries to cast them to string like so:
items.add((String)model.getElementAt(i));
However this will fail when the list item is a complex object instead of a simple string. But since all objects in Java implement the toString() method, instead of doing a cast, if we call toString() method not only it will not fail, but will be more compatible with lists that have objects which contain strings and implement toString(). So my proposal is to change getListValues() to iterate items like so:
items.add(model.getElementAt(i).toString());
This shouldn't break anything and will increase compatibility with applications that use lists with objects. Application developers can use this opportunity to increase compatibility with Robot for automation on applications that use may customized GUI objects.
PS: since it is such a small change I don't think it deserves a pull request for this. Let me know if you think i'm wrong.
The text was updated successfully, but these errors were encountered:
@im2geek4you I think it all depends on how the developer implemented the list items. Suppose we have a list(Swing list) of "Vehicle" class objects. If I am not wrong, toString() will return something like this: Vehicle@1fee6fc and not some text unless the developer overrides the default "toString()" method.
For e.g. public String toString(){ return name; }
The SwingLibrary keyword "Get List Values" currently only works if the list items are strings, however in some cases the list items are other objects (which in turn can have strings inside). The getListValues() method in ListOperator.java iterates all list items and tries to cast them to string like so:
items.add((String)model.getElementAt(i));
However this will fail when the list item is a complex object instead of a simple string. But since all objects in Java implement the toString() method, instead of doing a cast, if we call toString() method not only it will not fail, but will be more compatible with lists that have objects which contain strings and implement toString(). So my proposal is to change getListValues() to iterate items like so:
items.add(model.getElementAt(i).toString());
This shouldn't break anything and will increase compatibility with applications that use lists with objects. Application developers can use this opportunity to increase compatibility with Robot for automation on applications that use may customized GUI objects.
PS: since it is such a small change I don't think it deserves a pull request for this. Let me know if you think i'm wrong.
The text was updated successfully, but these errors were encountered: