1 46 package groovy.swing.impl; 47 48 import java.awt.GridBagConstraints ; 49 import java.util.ArrayList ; 50 import java.util.Iterator ; 51 import java.util.List ; 52 53 59 public class TableLayoutRow implements Startable { 60 61 private TableLayout parent; 62 private List cells = new ArrayList (); 63 private int rowIndex; 64 65 public TableLayoutRow(TableLayout tableLayoutTag) { 66 this.parent = tableLayoutTag; 67 } 68 69 72 public void addCell(TableLayoutCell tag) { 73 tag.getConstraints().gridx = cells.size(); 74 cells.add(tag); 75 } 76 77 public void start() { 78 rowIndex = parent.nextRowIndex(); 79 80 for (Iterator iter = cells.iterator(); iter.hasNext(); ) { 82 TableLayoutCell cell = (TableLayoutCell) iter.next(); 83 GridBagConstraints c = cell.getConstraints(); 84 85 if ( iter.hasNext() ) { 87 c.gridwidth = GridBagConstraints.RELATIVE; 89 } 90 else { 91 c.gridwidth = GridBagConstraints.REMAINDER; 93 } 94 c.gridy = rowIndex; 95 96 parent.addCell(cell); 98 } 99 } 100 101 104 107 public int getRowIndex() { 108 return rowIndex; 109 } 110 111 } 112 | Popular Tags |