3 import javajs.awt.BorderLayout;
4 import javajs.awt.LayoutManager;
7 public class JPanel extends JComponent {
9 //private LayoutManager layoutManager;
13 private int nElements;
14 private JComponent last;
18 * @param manager ignored. we just use the layout designations with a grid
20 public JPanel(LayoutManager manager) {
22 //this.layoutManager = manager;
23 grid = new Grid(10,10);
26 public void add(JComponent btn, Object c) {
27 last = (++nElements == 1 ? btn : null);
28 if (c instanceof String) {
29 if (c.equals(BorderLayout.NORTH))
30 c = new GridBagConstraints(0, 0, 3, 1, 0, 0, GridBagConstraints.CENTER,
32 else if (c.equals(BorderLayout.SOUTH))
33 c = new GridBagConstraints(0, 2, 3, 1, 0, 0, GridBagConstraints.CENTER,
35 else if (c.equals(BorderLayout.EAST))
36 c = new GridBagConstraints(2, 1, 1, 1, 0, 0, GridBagConstraints.EAST,
38 else if (c.equals(BorderLayout.WEST))
39 c = new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST,
42 c = new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.CENTER,
45 grid.add(btn, (GridBagConstraints) c);
49 public String toHTML() {
52 grid = new Grid(1, 1);
53 grid.add(last, new GridBagConstraints(0, 0, 1, 1, 0, 0,
54 GridBagConstraints.CENTER, 0, null, 0, 0));
58 sb.append("\n<div id='" + id + "' class='JPanel' style='"
59 + getCSSstyle(100, 100) + "'>\n");
60 sb.append("\n<span id='" + id + "_minimizer' style='width:" + minWidth
61 + "px;height:" + minHeight + "px;'>");
62 sb.append(grid.toHTML(id));
64 sb.append("\n</div>\n");