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

win32: There are 5 pixels before and after the text displayed in a TextField

XMLWordPrintable

    • b04
    • x86
    • generic, windows_95

        The starting point of the first character of the text inside a TextField is after 5 pixel (more or less) if using Windows95 and 1 pixel if using NT 4.0 or Solaris 2.x.
        The same number of pixels is added at the end of the TextField, so the field is larger on Windows95 and you cannot create a useful and portable stack of numeric textfields (TextFields and Label and so on) to be used in an application with SubTotals and Totals. It is not possible to solve the problem using any Layout Manager nor changing fonts. You can see the same behavior using jdk 1.1.5 or 1.2beta3. See the following example:

        import java.awt.*;

        public class TestField {

                public static void main(String[] args) {

                        Frame frame = new Frame("Frame with a text field & a label");
                        frame.setBackground(Color.black);
                        frame.setLayout(new GridLayout(2,1));

                        // different position of text on Windows95
                        TextField text_field = new TextField("Left Textfield");
                        text_field.setBackground(Color.yellow);
                        frame.add(text_field);
                        System.out.println("Caret position: " +
        text_field.getCaretPosition());

                        Label label = new Label("Left Label");
                        label.setBackground(Color.blue);
                        frame.add(label);

                        frame.setBounds(50,50,300,300);
                        frame.setVisible(true);
                }
        }

              duke J. Duke
              cmassi Claudio Massi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: