Skip to content

JDK-8314731 : Add support for the alt attribute in the image type input HTML tag #26

@scientificware

Description

@scientificware

The purpose of this issue is to Add support for the alt attribute in the image type input HTML

This is referenced in Java Bug Database as

This is tracked in JBS as

According HTML 3.2 specification

alt is not an attribute of the input element.

According HTML 4.01 specifications :

... For accessibility reasons, authors should provide alternate text for the image via the alt attribute. ...

This feature is not implemented in FormView.java.

Screenshot_20230817_025316

Left before the patch and right after the patch.

Related Pull Request :

Related Issue Report :

⚠️ This also affects the HTML 32 DTD

Click here to see the code
 import java.awt.BorderLayout;
 import java.awt.Dimension;
 import javax.swing.JEditorPane;
 import javax.swing.JFrame;
 import javax.swing.JScrollPane;
 import javax.swing.SwingUtilities;
 import javax.swing.text.Document;
 import javax.swing.text.html.HTMLEditorKit;
 import javax.swing.text.html.StyleSheet;

 public class HTMLAddsSupportAltInputTag {
   public static void main(String[] args) {
     new HTMLAddsSupportAltInputTag();
   }

   public HTMLAddsSupportAltInputTag() {
     SwingUtilities.invokeLater(new Runnable(){
       public void run(){
         JEditorPane jEditorPane = new JEditorPane();
         jEditorPane.setEditable(false);
         JScrollPane scrollPane = new JScrollPane(jEditorPane);
         HTMLEditorKit kit = new HTMLEditorKit();
         jEditorPane.setEditorKit(kit);
        StyleSheet styleSheet = kit.getStyleSheet();
         styleSheet.addRule("""
             body {
                 color: #000;
                 font-family:times;
                 margin: 4px;
             }
             """);
         String htmlString = """
             <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:none_oracle_logo_50x50.jpg" alt="Logo Oracle JPG">
                     <p>
                     <input type=image name=point src="files:none_oracle_logo_50x50.jpg">
                 </body>
             </html>
             """;
         Document doc = kit.createDefaultDocument();
         jEditorPane.setDocument(doc);
         jEditorPane.setText(htmlString);
         JFrame jf = new JFrame("CSS named colors Test");
         jf.getContentPane().add(scrollPane, BorderLayout.CENTER);
         jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         jf.setSize(new Dimension(400,200));
         jf.setLocationRelativeTo(null);
         jf.setVisible(true);
       }
     });
   }
 }

The image to use with de code above, save it with the name : oracle_logo_50x50.jpg
oracle_logo_50x50.jpg

Status

  • This Enhancement Request is not yet accepted so it's internaly referenced in Java Bug Database as : JI-9075849

    Click here to see details

    Bug Report Submission Complete

    Thank You

    Thank you for taking the time to provide us with your details.
    Bug Report Submission Complete

    Thank You

    Thank you for taking the time to provide us with your details.
    What's Next

    We will review your report and have assigned it an internal review ID : 9075849. Depending upon the completeness of the report and our ability to reproduce the problem, either a new bug will be posted, or we will contact you for further information.

    We will try to process all newly posted bugs in a timely manner, but we make no promises about the amount of time in which a bug will be fixed. If you just reported a bug that could have a major impact on your project, consider using one of the technical support offerings available at Oracle Support.

    Thank you again for using this site.

  • Referenced in Java Bug Database.

Metadata

Metadata

Labels

AuthorContributed a patch to fix this issueEnhancementNew feature or requestFixed jdk 26+Fixed issue. Since jdk 26.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions