JDK-4235341 : HTML text in JEditorPane does not antialias correctly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-05-04
  • Updated: 2001-05-21
  • Resolved: 2001-05-21
Related Reports
Duplicate :  
Description

Name: vi73552			Date: 05/04/99


When displaying HTML text using a JEditorPane and turning on the antialias (and antialias text, 
to be sure) rendering hint, the text does not appear antialiased.  Various graphics in the HTML, 
such as underlining, do appear antialiased, but the text itself does not.

Here's the code:

import javax.swing.*;
import java.awt.*;

public class AntiAliasTest extends JFrame {

	public static void main(String[] args) {
		JFrame frame = new AntiAliasTest();
		frame.setSize(400, 400);
		frame.show();
	}
	
	public AntiAliasTest() {
		getContentPane().setLayout(new BorderLayout());
		getContentPane().add
			(new TextPanel
				("<html><body>This is a test<br><u>This is a test</u><br><font size=\"+3\">This is a test<br><u>This is a test</u><br><font></body></html>"),
			BorderLayout.CENTER);
	}
	
	
	public class TextPanel extends JEditorPane {
		public TextPanel
			(String text) {
			setContentType("text/html");
			setText(text);
		}

		public void paint(Graphics g) {
			Graphics2D g2d = (Graphics2D)g;
			g2d.setRenderingHint
				(RenderingHints.KEY_ANTIALIASING,
				RenderingHints.VALUE_ANTIALIAS_ON);
			g2d.setRenderingHint
				(RenderingHints.KEY_TEXT_ANTIALIASING,
				RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
			super.paint(g2d);
		}
	}
}

Here's the version info:
C:\users\jclover\work\checkout\shell\classes>java -version
java version "1.2"
Classic VM (build JDK-1.2-V, native threads)

C:\users\jclover\work\checkout\shell\classes>java -fullversion
JAVA.EXE full version "JDK-1.2-V"
(Review ID: 57812) 
======================================================================

Comments
EVALUATION It looks anti-aliased in 1.3, however the font metrics are incorrect (using the 1.1 compatible api). timothy.prinzing@eng 1999-09-15 Name: apR10133 Date: 05/21/2001 I close this bug as duplicate because the problem of incorrect font metrics for antialiased text is already reported at 4194023. ###@###.### ======================================================================
24-08-2004