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

Bug in TextField Constructors

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • None
    • 1.2.2
    • client-libs
    • x86
    • windows_2000

    Description



      Name: sl110371 Date: 07/27/2000


      java version "1.2.2"
      Classic VM (build JDK-1.2.2-001, native threads, symcjit)


        Bug Report
        Bug in TeXtField constructors
       
      public TextField (int columns)
      public TextField (String text, int columns)


      The above constructor's creates a TextField with text as
      its content and a width of columns.Some constructors
      permit you to set the width of the TextField on the screen,
      but the current LayoutManager may change it.
      if u give negative value in the columns Textfield constructor
      accepts and produce its default size.

      Alternate solutions
      produce some negative exception for it.

      //Example for TextField
      import java.applet.*;
      import java.awt.*;
      import java.awt.event.*;
      public class TestText extends Applet implements ActionListener
      {

      TextField name;
      TextField no;
      TextField age;

      public void init()
      {
      setLayout(new FlowLayout(FlowLayout.CENTER));
      name = new TextField("Bye", -6);//negative value of column's width
      no = new TextField(-10);
      age = new TextField(-90);
      add(name);
      add(no);
      add(age);
      name.addActionListener(this);
      no.addActionListener(this);
      age.addActionListener(this);
      }

      public void actionPerformed(ActionEvent ae)
      {
      repaint();
      }

      public void paint(Graphics g)
      {
      g.drawString(name.getText(),20,20);
      g.drawString(no.getText(),20,40);
      g.drawString(age.getText(),20,60);
      }
      }
      (Review ID: 107685)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              ehawkessunw Eric Hawkes (Inactive)
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: