[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[albireo-dev] Re: GridLayout view

Gordon Hirsch wrote:
> I've also checked in a new view, GridLayoutView, that tests this code. 

Thanks! I found the default height of the Swing tables (403 pixels) a bit
excessive, so I reduced this to 200 pixels - still enough to see how a
bad preferred height in a panel can kill the aesthetics of the entire panel.

Bruno


Index: src/org/eclipse/albireo/examples/plugin/views/GridLayoutView.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.albireo/org.eclipse.albireo.examples.plugin/src/org/eclipse/albireo/examples/plugin/views/GridLayoutView.java,v
retrieving revision 1.2
diff -c -3 -r1.2 GridLayoutView.java
*** src/org/eclipse/albireo/examples/plugin/views/GridLayoutView.java	27 Jan 2008 01:24:26 -0000	1.2
--- src/org/eclipse/albireo/examples/plugin/views/GridLayoutView.java	1 Feb 2008 21:36:37 -0000
***************
*** 1,5 ****
--- 1,6 ----
  package org.eclipse.albireo.examples.plugin.views;
  
+ import java.awt.Dimension;
  import java.util.Vector;
  
  import javax.swing.JButton;
***************
*** 23,28 ****
--- 24,35 ----
  import org.eclipse.swt.widgets.TableItem;
  import org.eclipse.ui.part.ViewPart;
  
+ /**
+  * This view arranges a 5 x 4 grid of controls in an SWT GridLayout.
+  * The elements in the grid can be either Swing controls or SWT controls.
+  * You can switch back and forth between Swing and SWT to see the differences
+  * in layout.
+  */
  public class GridLayoutView extends ViewPart {
  
      public static String ID="org.eclipse.albireo.examples.plugin.gridLayoutView"; //$NON-NLS-1$
***************
*** 31,37 ****
      private Control grid;
  
      public GridLayoutView() {
-         // TODO Auto-generated constructor stub
      }
      
      // Embedding a Swing button is not really a good idea in a real application. This is 
--- 38,43 ----
***************
*** 84,89 ****
--- 90,99 ----
              
              JScrollPane scrollPane = new JScrollPane(table);
  //            scrollPane.setBorder(new EmptyBorder(0,0,0,0));
+             // Reduce the default height of 403 pixels.
+             scrollPane.setPreferredSize(
+                 new Dimension(scrollPane.getPreferredSize().width,
+                               Math.min(scrollPane.getPreferredSize().height,200)));
              
              return scrollPane;
          }