JDK-4527482 : JTextField and JLabel do not display correct font under Windows L&F in 1.4beta3
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt,windows_2000
  • CPU: x86
  • Submitted: 2001-11-15
  • Updated: 2003-09-05
  • Resolved: 2003-09-05
Related Reports
Duplicate :  
Description

Name: ddT132432			Date: 11/14/2001


java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)

JTextField does not display the correct font under Windows L&F.  Run the
following program and compare the font displayed in the JLabel and the font
displayed in the JTextField.


Application1.java
=================
import javax.swing.UIManager;
import java.awt.*;

public class Application1
{
    private boolean packFrame = false;

    /**Construct the application*/
    public Application1()
    {
        Frame1 frame = new Frame1();
        //Validate frames that have preset sizes
        //Pack frames that have useful preferred size info, e.g. from their layout
        if (packFrame)
        {
            frame.pack();
        }
        else
        {
            frame.validate();
        }
        //Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height)
        {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width)
        {
            frameSize.width = screenSize.width;
        }
        frame.setLocation((screenSize.width - frameSize.width) / 2,(screenSize.height - frameSize.height) / 2);
        frame.setVisible(true);
    }
    /**Main method*/
    public static void main(String[] args)
    {
        try
        {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        }
        catch(Exception e)
        {
            System.out.println("look and feel setup error");
        }
        new Application1();
    }
}


Frame1.java
===========
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Frame1 extends JFrame
{
    private JPanel contentPane;
    private FlowLayout flowLayout1 = new FlowLayout();
    private JLabel jLabel1 = new JLabel();
    private JTextField jTextField1 = new JTextField();

    /**Construct the frame*/
    public Frame1()
    {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try
        {
            jbInit();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    /**Component initialization*/
    private void jbInit() throws Exception
    {
        //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
        contentPane = (JPanel) this.getContentPane();
        jLabel1.setBorder(BorderFactory.createLineBorder(Color.black));
        jLabel1.setText("Correct Windows L&F font");
        contentPane.setLayout(flowLayout1);
        this.setSize(new Dimension(400, 300));
        this.setTitle("Frame Title");
        jTextField1.setText("Correct Windows L&F font???");
        contentPane.add(jLabel1, null);
        contentPane.add(jTextField1, null);
    }
    /**Overridden so we can exit when window is closed*/
    protected void processWindowEvent(WindowEvent e)
    {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING)
        {
            System.exit(0);
        }
    }
}
(Review ID: 135291) 
======================================================================

Comments
EVALUATION This was fixed as part of 4419964. It broke because of some changes in 1.5 and will be refixed in 1.5 as part of 4918331. ###@###.### 2003-09-05
05-09-2003