Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8215980

Sub-pixel text anti-aliasing on translucent (non-opaque) windows

    Details

    • Subcomponent:
      2d
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      OS: Windows 10

      specname: Java Virtual Machine Specification
      specvendor: Oracle Corporation
      specvendor: 11
      vmname: OpenJDK 64-Bit Server VM
      vmvendor: Oracle Corporation
      vmversion: 11+28

      A DESCRIPTION OF THE PROBLEM :
      When drawing text on a non-opaque window the text is not sub-pixel aa but uses a gray aa. I do not know if this is a regression but it didn't work in Java8 (any of the updates) either. If this is a misunderstanding of the APIs on my part, then consider this as a bug filed against the documentation.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the supplied code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The text in the button should be sub-pixel anti-aliased.
      ACTUAL -
      The text is not sub-pixel anti-aliased.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.ActionEvent;

      public class SubpixelAAOnTranslucentWindow {

          public static void main(String args[]) throws Exception {
              SwingUtilities.invokeLater(() -> {
                  JFrame frame = new JFrame("Title");
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  frame.add(new JButton(new AbstractAction("Button text that should be sub-pixel AA but isn't!") {
                      @Override
                      public void actionPerformed(ActionEvent e) {
                          frame.dispose();
                          System.exit(0);
                      }
                  }));
                  frame.setUndecorated(true);
                  frame.setBackground(new Color(0, 0, 0, 0));
                  frame.setBounds(500, 500, 500, 500);
                  frame.setVisible(true);
              });
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      There is no workaround to my knowledge, unless you consider not using a transparent window. Sub-pixel AA has worked beautifully in opaque windows since Java 6.

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              psadhukhan Prasanta Sadhukhan
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: