--- /dev/null
+// FormFrame.java\r
+// $Id: FormPanel.java,v 1.1 2010/06/15 12:27:23 smhuang Exp $\r
+// (c) COPYRIGHT MIT and INRIA, 1996.\r
+// Please first read the full copyright statement in file COPYRIGHT.html\r
+\r
+package org.w3c.tools.forms ;\r
+\r
+import java.awt.Component;\r
+import java.awt.Container;\r
+import java.awt.Dimension;\r
+import java.awt.Graphics;\r
+import java.awt.GridBagConstraints;\r
+import java.awt.GridBagLayout;\r
+import java.awt.Insets;\r
+import java.awt.Label;\r
+import java.awt.Panel;\r
+\r
+public class FormPanel extends Panel {\r
+ /**\r
+ * Our associated form manager.\r
+ */\r
+ FormManager manager = null ;\r
+ /**\r
+ * Our layout manager.\r
+ */\r
+ GridBagLayout gb = null ;\r
+ /**\r
+ * Field's title constraints.\r
+ */\r
+ GridBagConstraints ct = null ;\r
+ /**\r
+ * Field's editor constraints.\r
+ */\r
+ GridBagConstraints cv = null ;\r
+\r
+ /**\r
+ * Add a field editor.\r
+ * @param title The title for the field.\r
+ * @param editor Its editor component.\r
+ */\r
+\r
+ protected void addField (String title, Component editor) {\r
+ Label label = new Label(title, Label.LEFT) ;\r
+ gb.setConstraints(label, ct) ;\r
+ add(label) ;\r
+ gb.setConstraints(editor, cv) ;\r
+ add(editor) ;\r
+ }\r
+\r
+ /**\r
+ * Some insets for the form panel. \r
+ */\r
+\r
+ public Insets insets() {\r
+ return new Insets(5, 5, 5, 5) ;\r
+ }\r
+\r
+ /**\r
+ * Darw a rectangle around the form panel.\r
+ */\r
+\r
+ public void paint (Graphics g) {\r
+ Dimension d = size();\r
+ g.drawRect(1, 1, d.width - 3, d.height - 3);\r
+ }\r
+\r
+ /**\r
+ * Create a new form panel for the given form manager.\r
+ */\r
+\r
+ FormPanel(FormManager manager) {\r
+ super() ;\r
+ // Create our layout manager:\r
+ gb = new GridBagLayout() ;\r
+ setLayout(gb) ;\r
+ // Create the title constraints:\r
+ ct = new GridBagConstraints() ;\r
+ ct.gridx = GridBagConstraints.RELATIVE ;\r
+ ct.anchor = GridBagConstraints.EAST ;\r
+ ct.weighty = 1.0 ;\r
+ // Create the value constraints:\r
+ cv = new GridBagConstraints() ;\r
+ cv.gridx = GridBagConstraints.RELATIVE ;\r
+ cv.gridwidth = GridBagConstraints.REMAINDER ;\r
+ cv.fill = GridBagConstraints.HORIZONTAL ;\r
+ cv.anchor = GridBagConstraints.WEST ;\r
+ cv.weightx = 1.0 ;\r
+ cv.weighty = 1.0 ;\r
+ }\r
+\r
+ \r
+}\r
+\r
+\r