JDK-4133940 : setFont on JTextArea doesn't work.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: x86
  • Submitted: 1998-04-30
  • Updated: 1998-05-16
  • Resolved: 1998-05-16
Related Reports
Duplicate :  
Description

Name: rm29839			Date: 04/30/98


setFont in JTextArea doesn't work under
Solaris/X86 (JDK 1.2 beta 3).
Even the NotePad demo of the JDK fails to
use the specified Monospaced font.
The following testcase demonstrates the bug.
The font should be Monospaced. Instead it is
a default proportional font.
If the Swing components are replaced with their
AWT counterparts (JTextArea==>TextArea, 
JFrame==>Frame), it works fine.
-----------------------------------------------
import java.awt.swing.JTextArea;
import java.awt.swing.JFrame;
import java.awt.Container;
import java.awt.Font;

class TT {
    static final String areaText = 
        "wwwwwWWWW\n" +
        "iiiiiIIII\n" 
        ;

    public static void main(String args[]){
        JTextArea area = new JTextArea(areaText);
        area.setFont(new Font("Monospaced",Font.PLAIN,24));

        JFrame frame = new JFrame();
        frame.getContentPane().add(area);
        frame.pack();
        frame.setSize(300,300);
        frame.setVisible(true);
        }
    }
(Review ID: 27973)
======================================================================