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

some LayoutManagers don't respect a Container's insets


    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 1.2.1, 1.3.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      generic, x86
    • OS:
      generic, windows_2000


      Name: sg39081 Date: 05/05/99

      It seems that some LayoutManagers don't pay attention to insets when
      the component they are in shrinks. David Geary's _Graphic Java_
      indicates that "layout managers will not place components inside a
      comtainer's insets." But, if you shrink the panel below, you'll see that
      the button in it is clearly drawn into the insets area. This occurs with both
      JDK 1.1.x and JDK 1.2.x and with lightweight and heavyweight components.
      BorderLayout and GridLayout work OK, FlowLayout and GridBagLayout don't.

      I would have expected that the LayoutManagers would use minimumLayoutSize
      so that the component shouldn't shrink beyond insets+minimalchildrenComponentSize;

      import java.awt.*;
      import javax.swing.*;

      public class BorderTest extends JPanel {

       public void paint(Graphics g) {
               Dimension s = getSize();
               for (int i=0; i<10; i++) {
                    g.drawLine(i, 0, i, s.height-1);
                    g.drawLine(0, i, s.width-1, i);
                    g.drawLine(0, s.height-i, s.width-1, s.height-i);
                    g.drawLine(s.width-1-i, 0, s.width-1-i, s.height-1);

       public Insets getInsets() {
               return new Insets(10, 10, 10, 10);

       public Insets insets() {
               return new Insets(10, 10, 10, 10);

       public static void main(String[] args) {
            JFrame f = new JFrame();
            BorderTest bt = new BorderTest();
            bt.add(new JButton("hi there xxxxxxxxxxxxxxxxxxxxxxxxxx"));
            f.setSize(100, 100);



      java version "1.2"
      Classic VM (build JDK-1.2-V, native threads)

      java full version "JDK-1.2-V"
      (Review ID: 57815)


          Issue Links



              • Assignee:
                rraysunw Richard Ray (Inactive)
                sgoodsunw Sheri Good (Inactive)
              • Votes:
                0 Vote for this issue
                0 Start watching this issue


                • Created: