1 46 package groovy.swing.impl; 47 48 import java.awt.Component ; 49 import java.awt.GridBagConstraints ; 50 import java.awt.GridBagLayout ; 51 import java.awt.Insets ; 52 import java.awt.LayoutManager ; 53 54 import javax.swing.JPanel ; 55 56 62 public class TableLayout implements ComponentFacade { 63 64 private JPanel panel = new JPanel (); 65 private int rowCount; 66 private int cellpadding; 67 68 public TableLayout() { 69 panel.setLayout(createLayoutManager()); 70 } 71 72 public Component getComponent() { 73 return panel; 74 } 75 76 public int getCellpadding() { 77 return cellpadding; 78 } 79 80 public void setCellpadding(int cellpadding) { 81 this.cellpadding = cellpadding; 82 } 83 84 87 public void addCell(TableLayoutCell cell) { 88 GridBagConstraints constraints = cell.getConstraints(); 89 constraints.insets = new Insets (cellpadding, cellpadding, cellpadding, cellpadding); 90 panel.add(cell.getComponent(), constraints); 91 } 92 93 96 public int nextRowIndex() { 97 return rowCount++; 98 } 99 100 103 106 protected LayoutManager createLayoutManager() { 107 return new GridBagLayout (); 108 } 109 } 110 | Popular Tags |