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

GridLayout within a gridlayout causes layout problems

XMLWordPrintable

    • sparc
    • solaris_2.4

      A frame in gridlayout with two panels where the first has a flowlayout and the
      second a gridlayout results in the second panel not being drawn properly. If the
      layout is only one level deep (i.e only the second panel in the frame), laying out
      of the components are done properly.

      Run test TextAreaTest1.java in src/share/test/awt. The appropriate links in the
      index.html file have not been added yet so please compile and run it by hand.

      Vijay

      [aim 1/22/96]
      This was also reported by an outside customer (src included below).

      import java.awt.*;
      import java.applet.*;

      public class NestedLayout extends java.applet.Applet
      {
      final int WIDTH = 650;
      final int HEIGHT =650;

      public void init()
      {
      LeftPanel leftPanel;
      Panel redPanel;

      GridBagLayout layout = new GridBagLayout();
      GridBagConstraints constraints = new GridBagConstraints();

      setLayout(layout);

      constraints.fill = GridBagConstraints.BOTH;
      constraints.gridheight = GridBagConstraints.REMAINDER;
      constraints.weightx = 0.5;
      constraints.weighty = 1.0;

      leftPanel = new LeftPanel();
      layout.setConstraints(leftPanel,constraints);
      add(leftPanel);

      redPanel = new Panel();
      redPanel.setBackground(Color.red);
      layout.setConstraints(redPanel,constraints);
      add(redPanel);

      resize(WIDTH,HEIGHT);
      }
      }

      class LeftPanel extends Panel
      {
      public LeftPanel()
      {
                      GridBagLayout layout = new GridBagLayout();
                      GridBagConstraints constraints = new GridBagConstraints();
      TextArea textArea;
      Panel yellowPanel;
       
                      setLayout(layout);
       
                      constraints.fill = GridBagConstraints.BOTH;
                      constraints.gridwidth = GridBagConstraints.REMAINDER;
      constraints.weightx = 1.0;
      constraints.weighty = 0.5;

                      textArea = new TextArea();
                      layout.setConstraints(textArea,constraints);
                      add(textArea);
      /*
      Panel panel = new Panel();
      panel.setBackground(Color.blue);
      layout.setConstraints(panel, constraints);
      add(panel);
      */
       
      yellowPanel = new Panel();
      yellowPanel.setBackground(Color.yellow);
                      layout.setConstraints(yellowPanel,constraints);
                      add(yellowPanel);
      }
      }

            rramsunw Ranganathan Ram (Inactive)
            vssriniv Vijay Srinivasan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: