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

JToolBar.getComponentAtIndex(int) throws ArrayIndexOutOfBoundsException

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2.2
    • CPU:
      sparc
    • OS:
      solaris_2.5.1
    • Verification:
      Verified

      Description



      Name: aaC67449 Date: 12/22/98


      JToolBar.getComponentAtIndex(int index) throws unexpected ArrayIndexOutOfBoundsException, when index is invalid, but should only return null

      javadoc says:"

      public Component getComponentAtIndex(int i)

            Returns the component at the specified index.
            Parameters:
                  i - the component's position, where 0=first
            Returns:
                  the Component at that position, or null for an invalid index"

      see example:
      -------------- Example ------------
      import javax.swing.*;

      public class Test{
          public static void main(String argv[]) {
              JToolBar c=new JToolBar();
      if(c.getComponentAtIndex(1)==null)
      System.out.println("Ok");
      else
      System.out.println("Failed");
          }
      }

      class MyAction extends AbstractAction {
          public void actionPerformed(ActionEvent e){}
      }
       

      --------------- output----------
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: No such child: 1
              at java.awt.Container.getComponent(Compiled Code)
              at javax.swing.JToolBar.getComponentAtIndex(Compiled Code)
              at Test.main(Compiled Code)

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              jshapirosunw Jeff Shapiro (Inactive)
              Reporter:
              aalievsunw Artem Aliev (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: