KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > trading > client > util > Constrain


1
2 // Copyright (C) 1998-1999
3
// Object Oriented Concepts, Inc.
4

5 // **********************************************************************
6
//
7
// Copyright (c) 1997
8
// Mark Spruiell (mark@intellisoft.com)
9
//
10
// See the COPYING file for more information
11
//
12
// **********************************************************************
13

14 package org.jacorb.trading.client.util;
15
16 import java.awt.*;
17
18 public class Constrain
19 {
20   /**
21    * Convenience routine for setting gridbag constraints.
22    */

23   public static void constrain(Container container, Component component,
24     int grid_x, int grid_y, int grid_width, int grid_height,
25     int fill, int anchor, double weight_x, double weight_y,
26     int top, int left, int bottom, int right, int ipadx,
27     int ipady)
28   {
29     GridBagConstraints c = new GridBagConstraints();
30     c.gridx = grid_x;
31     c.gridy = grid_y;
32     c.gridwidth = grid_width;
33     c.gridheight = grid_height;
34     c.fill = fill;
35     c.anchor = anchor;
36     c.weightx = weight_x;
37     c.weighty = weight_y;
38
39     if (top + bottom + left + right > 0)
40       c.insets = new Insets(top, left, bottom, right);
41     c.ipadx = ipadx;
42     c.ipady = ipady;
43
44     ((GridBagLayout)container.getLayout()).setConstraints(component, c);
45     container.add(component);
46   }
47
48
49   /**
50    * Convenience routine for setting gridbag constraints.
51    */

52   public static void constrain(Container container, Component component,
53     int grid_x, int grid_y, int grid_width, int grid_height,
54     int fill, int anchor, double weight_x, double weight_y,
55     int top, int left, int bottom, int right)
56   {
57     constrain(container, component, grid_x, grid_y, grid_width,
58       grid_height, fill, anchor, weight_x, weight_y, top, left,
59       bottom, right, 0, 0);
60   }
61
62   /**
63    * Convenience routine for setting gridbag constraints.
64    */

65   public static void constrain(Container container, Component component,
66           int grid_x, int grid_y, int grid_width, int grid_height)
67   {
68     constrain(container, component, grid_x, grid_y,
69         grid_width, grid_height, GridBagConstraints.NONE,
70         GridBagConstraints.NORTHWEST, 0.0, 0.0, 0, 0, 0, 0);
71   }
72
73
74   /**
75    * Convenience routine for setting gridbag constraints.
76    */

77   public static void constrain(Container container, Component component,
78           int grid_x, int grid_y, int grid_width, int grid_height,
79           int fill, int anchor)
80   {
81     constrain(container, component, grid_x, grid_y,
82         grid_width, grid_height, fill, anchor,
83         0.0, 0.0, 0, 0, 0, 0);
84   }
85
86
87   /**
88    * Convenience routine for setting gridbag constraints.
89    */

90   public static void constrain(Container container, Component component,
91     int grid_x, int grid_y, int grid_width, int grid_height,
92     int top, int left, int bottom, int right)
93   {
94     constrain(container, component, grid_x, grid_y,
95         grid_width, grid_height, GridBagConstraints.NONE,
96         GridBagConstraints.NORTHWEST,
97         0.0, 0.0, top, left, bottom, right);
98   }
99 }
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
Popular Tags