]> code.citadel.org Git - citadel.git/blob - shaggy/PairPanel.java
*** empty log message ***
[citadel.git] / shaggy / PairPanel.java
1 /* PairPanel.java
2  * Utility class so I don't have to think about GridBagLayout
3  */
4
5 import javax.swing.*;
6 import java.awt.*;
7
8 public class PairPanel extends JPanel {
9   GridBagLayout           gbLayout;
10   GridBagConstraints      gbLeft, gbRight;
11
12   PairPanel() {
13     this( 0, 0 );
14   }
15
16   PairPanel( int x, int y ) {
17     Insets      i = null;
18
19     if( x + y != 0 )
20       i = new Insets( x, y, x, y );
21
22     setLayout( gbLayout = new GridBagLayout() );
23
24     gbLeft = new GridBagConstraints();
25     gbLeft.gridwidth = 1;
26     //    gbLeft.ipadx = x;
27     //    gbLeft.ipady = y;
28     if( i != null )
29       gbLeft.insets = i;
30     gbLeft.anchor = GridBagConstraints.EAST;
31
32     gbRight = new GridBagConstraints();
33     //    gbRight.ipadx = x;
34     //    gbRight.ipady = y;
35     if( i != null )
36       gbRight.insets = i;
37     gbRight.gridwidth = GridBagConstraints.REMAINDER;
38     gbRight.anchor = GridBagConstraints.WEST;
39   }
40
41   public void addLeft( Component c ) {
42     gbLayout.setConstraints( c, gbLeft );
43     add( c );
44   }
45
46   public void addRight( Component c ) {
47     gbLayout.setConstraints( c, gbRight );
48     add( c );
49   }
50 }