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

setBounds doesn't enlarge Component

    XMLWordPrintable

Details

    • b19
    • 7
    • b25
    • x86
    • windows_xp, windows_vista
    • Not verified

    Description

      FULL PRODUCT VERSION :
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b22)
      Java HotSpot(TM) Client VM (build 11.0-b08, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      I tried to resize components for example: java.awt.TextField without success.

      I set initial bounds of a TextField in a Panel with null Layout. Everything is ok. I tried to change bounds automatically and the component doesn't change the size.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      - Create an empty applet
      - set null layout to applet container
      - define textfield with bounds for example 10, 10, 50, 20
      - add textfield to applet container
      - show applet
      - change bounds to 10, 10 , 2, 2 (through program logic)
      - change bounds back to 10, 10, 50, 20 (through program logic)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      painted textield with "visible" bounds 10, 10 , 50, 20
      ACTUAL -
      invalid repainted textfield

      bounds are 10, 10 , 50, 20 but I don't see the textfield on screen, as expected.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package jdk.test;

      import java.applet.Applet;
      import java.awt.Button;
      import java.awt.Rectangle;
      import java.awt.TextField;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      /**
       * Simple setBounds and resize test
       *
       * @author JRx
       */
      public class BugReportApplet extends Applet
                                    implements ActionListener
      {
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          // Members
          //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      /** default username bounds */
      private static final Rectangle REC_USERNAME = new Rectangle(10, 10, 80, 20);

      /** input username */
      private TextField tfUsername;

      /** test button */
      private Button butResize;

      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          // Override
          //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      @Override
      public void start()
      {

      }

      @Override
      public void stop()
      {

      }

      @Override
      public void init()
      {
      /* Username */

      tfUsername = new TextField(10);
      tfUsername.setBounds(BugReportApplet.REC_USERNAME);

      butResize = new Button("Resize");
      butResize.setBounds(10, 40, 50, 25);

      butResize.addActionListener(this);

      /* MAIN LAYOUT */

      setLayout(null);

      add(tfUsername);

      add(butResize);
      }

      @Override
      public void destroy()
      {

      }

      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          // Interfaces
          //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

      //ACTIONLISTENER

      public void actionPerformed(ActionEvent ae)
      {
      Rectangle rec = tfUsername.getBounds();


      if (rec.width < 10)
      {
      tfUsername.setBounds(BugReportApplet.REC_USERNAME);
      }
      else
      {
      tfUsername.setBounds(10, 10, 5, 5);
      }
      }

      } //BugReportApplet

      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              anthony Anthony Petrov (Inactive)
              dav Andrei Dmitriev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: