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

Size of the JToolBar object isn't set, while it isn't shown.

XMLWordPrintable

    • sparc
    • solaris_2.5.1



      Name: aaC67449 Date: 09/17/97



      JToolBar.setSize(...) doesn't implemented for the object while it isn't shown, so getDockingConstraint(...) and canDock(...) methods work incorrect.
      Swing version is 0.4.1

      -------------------Example-----------------------------------

      import com.sun.java.swing.*;
      import java.awt.*;
      public class Test {

      public static void main( String argv[] ) {

        JFrame f=new JFrame();
        f.setSize(300,300);
        
        JToolBar c=new JToolBar(); // Create JToolBar object
        c.add(new DefaultAction());
        c.add(new DefaultAction());

      // work arround
      // c.setSize(c.getPreferredSize());

        System.out.println("Size is "+c.getSize()+" Preferred size is "+c.getPreferredSize());

      // test getDockingConstraint
        
        if(!(c.getDockingConstraint(f,new Point(299,150)).equals( BorderLayout.EAST)))
            System.out.println("Failed.c.getDockingConstraint(f,299,150) return "+c.getDockingConstraint(f,new Point(299,150))+", but must be "+ BorderLayout.EAST);
        else
            System.out.println("Passed");
        
       // test canDock
       
         if(!c.canDock(f,new Point(299,150)))
            System.out.println("Failed. c.canDock(f,299,150) reurn false");
        else
            System.out.println("Passed");
       
       System.exit(0);
             
      }

      }

      -------------------Output------------------------------------
      Size is java.awt.Dimension[width=0,height=0] Preferred size is java.awt.Dimension[width=46,height=25]
      Failed.c.getDockingConstraint(f,299,150) return North, but must be East
      Failed. c.canDock(f,299,150) reurn false

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

            gsaab Georges Saab
            aalievsunw Artem Aliev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: