On Mon, 3 Jul 2023 09:14:23 GMT, Abhishek Kumar <abhis...@openjdk.org> wrote:
> > What if `JComboBox` uses a non-standard renderer which takes a property > > from an object? Let's assume, `JComboBox` is populated with `Rectangle` > > objects, a custom renderer is set which displays the value of the `bottom` > > field in the combo box. Your code, if I understand it correctly, will > > default to _full rectangle_ rather than what's really displayed. > > You were right. At least in this case the current fix returns > _full_rectangle_ dimension in a string form instead of the text displayed in > JComboBox. Thank you for confirming it. > I had a doubt here if a custom renderer is used to populate the JComboBox, > isn't it required to `override` the `toString` method to return useful > information from user end? No, it's not required to override the `toString` method if the programmer doesn't use it. > If not then I think it is required to look for alternate fix, probably to get > the displayed text from JComboBox and set it as an accessibleName. Could be… How would you get the text? It should be provided by a renderer… > > How does JTable handle this kind of situation? Or JList? > > I case of JTable and JList, the accessible context is of type JLabel which > returns the accessibleName in string format. This doesn't really answer the question. Do `JTable` and `JList` correctly display the magnified text when a custom renderer is used? In the case with rectangle and a custom renderer? Do they still display text from `toString`? If neither `JTable` nor `JList` handle this situation, it's okay to go with `toString` as you implemented. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14497#discussion_r1250718052