01: /*
02: * Copyright 2006 Ethan Nicholas. All rights reserved.
03: * Use is subject to license terms.
04: */
05: package jaxx.runtime.swing;
06:
07: import java.awt.*;
08: import javax.swing.*;
09:
10: /** Panel which uses a {@link GridBagLayout} by default.
11: *
12: *@author Ethan Nicholas
13: */
14: public class Table extends JPanel {
15: public static final Insets DEFAULT_INSETS = new Insets(3, 3, 3, 3);
16:
17: private GridBagConstraints tableConstraints = new GridBagConstraints();
18: private GridBagConstraints rowConstraints = null;
19: private GridBagConstraints cellConstraints = null;
20:
21: public Table() {
22: super .setLayout(new GridBagLayout());
23:
24: tableConstraints.insets = DEFAULT_INSETS;
25: }
26:
27: public void setLayout(LayoutManager layout) {
28: // do nothing
29: }
30:
31: public GridBagConstraints getTableConstraints() {
32: return tableConstraints;
33: }
34:
35: public GridBagConstraints getRowConstraints() {
36: return rowConstraints;
37: }
38:
39: public GridBagConstraints getCellConstraints() {
40: return cellConstraints;
41: }
42:
43: public void newRow() {
44: tableConstraints.gridy++;
45: rowConstraints = (GridBagConstraints) tableConstraints.clone();
46: }
47:
48: public void newCell() {
49: rowConstraints.gridx++;
50: cellConstraints = (GridBagConstraints) rowConstraints.clone();
51: }
52: }
|