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

Left and right most characters in JTextField is getting chopped

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.4.2
    • client-libs
    • Cause Known
    • x86
    • windows_2000

      FULL PRODUCT VERSION :
      JRE 1.4.2 and 1.5.0_06

      ADDITIONAL OS VERSION INFORMATION :
      WINDOWS 2000 and XP

      A DESCRIPTION OF THE PROBLEM :
      When the font of the text field field is set to "Courier New" Bold and 12 pts, The following problems are observed.

      1. The text in the left and right most characters are getting cut partially.
      2. When we select the text using mouse the text is dancing left and right.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

      The following are the conditions where this behaviour is observed:

      1. Certain wide characters like M, R and W which are chopped when they occur at the left and right edges.
      2. The text field is filled to its capacity interms of number of characters.
      3. Only for MONOSPACE fonts (we are using "Courier New" font).
      4. BOLD and 12 pts



      Following is the code to reproduce the above problems.

      public class FontTest
      {
      public static void main(String[] a)
      {
      javax.swing.JFrame testFrame = new javax.swing.JFrame("Test");
      testFrame.setBounds(320,320,150,150);

      testFrame.getContentPane().setLayout(new FlowLayout());
                      JTextField field=new JTextField("MTEXTR");
                      field.setColumns(6);
                      field.setFont(new Font("Courier New",Font.BOLD,12));
                      field.setEditable(false);
                      field.setEnabled(false);
                      field.setDisabledTextColor(Color.BLACK);
                      
                      testFrame.getContentPane().add(field);
      testFrame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
                      testFrame.setVisible(true);
      }
      }


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Color;
      import java.awt.FlowLayout;
      import java.awt.Font;

      import javax.swing.JTextField;


      public class FontTest
      {
      public static void main(String[] a)
      {
      javax.swing.JFrame testFrame = new javax.swing.JFrame("Test");
      testFrame.setBounds(320,320,150,150);

      testFrame.getContentPane().setLayout(new FlowLayout());
                      JTextField field=new JTextField("MTEXTR");
                      field.setColumns(6);
                      field.setFont(new Font("Courier New",Font.BOLD,12));
                      field.setEditable(false);
                      field.setEnabled(false);
                      field.setDisabledTextColor(Color.BLACK);
                      
                      testFrame.getContentPane().add(field);
      testFrame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
                      testFrame.setVisible(true);
      }
      }
      ---------- END SOURCE ----------

            peterz Peter Zhelezniakov
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: