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

JTextField getColumnWidth is inaccurate

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.1.7, 1.3.0
    • client-libs
    • generic, x86
    • generic, windows_95

      Name: vi73552 Date: 03/25/99

      The JTextField getColumnWidth method should return
      a width that is the average of common characters for
      the font, instead of just returning the width of the
      character 'm'. As currently implemented, getColumnWidth
      causes JTextFields to be wider than requested. This
      complicates AWT to swing conversions since column
      widths need to be adjusted.
      (Review ID: 55401)
      ======================================================================

      Name: mc57594 Date: 01/05/2000
      JRE build 1.3beta-0
      Hotspot build 1.3beta-0

      When the number of columns is specified for a JTextField, the preferred width
      calculated for the field is too small. The documentation states the column
      width is that of the character 'm' of the font in use.

      See attached program. Number of columns is set to 4, but enter 4 'm's in the
      field and only 3.5 are visible. This occurs with the Metal/Java look and feel.

      ----------------------------------------------------------------------------
      import javax.swing.*;

      public class Test2
      {
          public static void main(String[] args)
          {
              JFrame f = new JFrame();
              JPanel p = new JPanel();
              JTextField t = new JTextField(4);
              p.add(t);
              f.getContentPane().add(p);
              f.pack();
              f.setVisible(true);
          }
      }
      (Review ID: 99006)
      ======================================================================

      The part about :
      "See attached program. Number of columns is set to 4, but enter 4 'm's in the
      field and only 3.5 are visible. This occurs with the Metal/Java look and feel."
      is covered by 4426701

      ###@###.### 2002-05-23

            idk Igor Kushnirskiy (Inactive)
            vasya Vassili Igouchkine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: