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

JTextField and JLabel do not display correct font under Windows L&F in 1.4beta3

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs
    • x86
    • windows_nt, windows_2000



      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)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            ddressersunw Daniel Dresser (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: