home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-04-08 | 784 b | 39 lines |
- //
- // Horizontal and Vertical Panel
- //
-
- import java.awt.*;
-
- class HVPanel extends Panel {
- static final int HORIZONTAL = 0;
- static final int VERTICAL = 1;
-
- HGridLayout hgrid;
- VGridLayout vgrid;
- int orientation;
-
- public HVPanel(int orient, int border, int gap, int left) {
- orientation = orient;
- Insets is = new Insets(border, border, border, border);
-
- if (orient == HORIZONTAL) {
- hgrid = new HGridLayout(is, gap, left);
- setLayout(hgrid);
- }
- else {
- vgrid = new VGridLayout(is, gap, left);
- setLayout(vgrid);
- }
- }
-
- public Component add(int size, Component comp) {
- if (orientation == HORIZONTAL)
- hgrid.setConstraints(comp, size);
- else
- vgrid.setConstraints(comp, size);
-
- add(comp);
- return comp;
- }
- }
-