On Mon, 23 Oct 2023 12:09:35 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>> src/java.desktop/share/classes/javax/swing/text/html/FormView.java line 282: >> >>> 280: @SuppressWarnings("deprecation") >>> 281: URL srcURL = new URL(base, srcAtt); >>> 282: ImageIcon icon = new ImageIcon(srcURL); >> >> You should probably pass `altAtt` as the `description` parameter, yet I'm >> unsure if it's ever used in this context. > >> You should probably pass `altAtt` as the `description` parameter, yet I'm >> unsure if it's ever used in this context. > > As I say, I'm unsure if it's used… The description could be exposed to > Accessibility API. By default, `ImageIcon` uses the URL as the description if > it isn't provided: > > https://github.com/openjdk/jdk/blob/99de9bb83ff70fe81c89751516a86a94c8f552be/src/java.desktop/share/classes/javax/swing/ImageIcon.java#L231-L233 > > Now that you handle the `alt` attribute, you can pass the description if it's > provided.  Did you have this in mind ? <html> <body> <input type=image name=point src="file:oracle_logo_50x50.jpg" alt="Logo Oracle JPG"> <p> <input type=image name=point src="file:oracle_logo_50x50.jpg"> <p> <input type=image name=point src="file:none_oracle_logo_50x50.jpg" alt="Logo Oracle JPG"> <p> <input type=image name=point src="file:none_oracle_logo_50x50.jpg"> <p> <input type=image name=point src="files:none_oracle_logo_50x50.jpg" alt="Logo Oracle JPG"> <p> <input type=image name=point src="files:none_oracle_logo_50x50.jpg"> <p> </body> </html> String srcAtt = (String) attr.getAttribute(HTML.Attribute.SRC); String altAtt = (String) attr.getAttribute(HTML.Attribute.ALT); if (altAtt == null) { altAtt = srcAtt; } JButton button; try { URL base = ((HTMLDocument)getElement().getDocument()).getBase(); @SuppressWarnings("deprecation") URL srcURL = new URL(base, srcAtt); ImageIcon icon = new ImageIcon(srcURL, altAtt); button = new JButton(icon); } catch (MalformedURLException e) { button = new JButton(altAtt == null ? srcAtt : altAtt); } ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15319#discussion_r1370684162