|
1 /* |
|
2 * CDDL HEADER START |
|
3 * |
|
4 * The contents of this file are subject to the terms of the |
|
5 * Common Development and Distribution License (the "License"). |
|
6 * You may not use this file except in compliance with the License. |
|
7 * |
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 * or http://www.opensolaris.org/os/licensing. |
|
10 * See the License for the specific language governing permissions |
|
11 * and limitations under the License. |
|
12 * |
|
13 * When distributing Covered Code, include this CDDL HEADER in each |
|
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 * If applicable, add the following below this CDDL HEADER, with the |
|
16 * fields enclosed by brackets "[]" replaced with your own identifying |
|
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 * |
|
19 * CDDL HEADER END |
|
20 */ |
|
21 |
|
22 /* |
|
23 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.util.swing; |
|
27 |
|
28 import java.awt.*; |
|
29 import javax.swing.JPanel; |
|
30 import com.oracle.solaris.vp.util.swing.layout.*; |
|
31 |
|
32 public class Form { |
|
33 // |
|
34 // Instance data |
|
35 // |
|
36 |
|
37 private Container container; |
|
38 private JPanel curRow; |
|
39 |
|
40 // |
|
41 // Constructors |
|
42 // |
|
43 |
|
44 public Form(Container container, VerticalAnchor vAnchor) { |
|
45 this.container = container; |
|
46 container.setLayout(new ColumnLayout(vAnchor)); |
|
47 }; |
|
48 |
|
49 // |
|
50 // Form methods |
|
51 // |
|
52 |
|
53 public JPanel addTable( |
|
54 int cols, int hGap, int vGap, HorizontalAnchor hAnchor, |
|
55 ColumnLayoutConstraint c) { |
|
56 |
|
57 TableLayout layout = new TableLayout(1, cols, hGap, vGap); |
|
58 layout.setHorizontalAnchor(hAnchor); |
|
59 |
|
60 curRow = new JPanel(layout); |
|
61 curRow.setOpaque(false); |
|
62 container.add(curRow, c); |
|
63 |
|
64 return curRow; |
|
65 } |
|
66 |
|
67 public JPanel addRow(HorizontalAnchor hAnchor, ColumnLayoutConstraint c) { |
|
68 RowLayout layout = new RowLayout(hAnchor); |
|
69 curRow = new JPanel(layout); |
|
70 curRow.setOpaque(false); |
|
71 container.add(curRow, c); |
|
72 |
|
73 return curRow; |
|
74 } |
|
75 |
|
76 public void add(Component c) { |
|
77 curRow.add(c); |
|
78 } |
|
79 |
|
80 public void add(Component c, Object constraint) { |
|
81 curRow.add(c, constraint); |
|
82 } |
|
83 |
|
84 public Container getContainer() { |
|
85 return container; |
|
86 } |
|
87 } |