private void add(Container parent,String key,JComponent widget,int x,int y){
  JLabel label=new JLabel(UIManager.getString(key + "Text",getLocale()));
  String mnemonic=(String)UIManager.get(key + "Mnemonic",getLocale());
  if (mnemonic != null) {
    try {
      label.setDisplayedMnemonic(Integer.parseInt(mnemonic));
    }
 catch (    NumberFormatException nfe) {
    }
    String mnemonicIndex=(String)UIManager.get(key + "MnemonicIndex",getLocale());
    if (mnemonicIndex != null) {
      try {
        label.setDisplayedMnemonicIndex(Integer.parseInt(mnemonicIndex));
      }
 catch (      NumberFormatException nfe) {
      }
    }
  }
  label.setLabelFor(widget);
  if (x < 0) {
    x=parent.getComponentCount() % 4;
  }
  if (y < 0) {
    y=parent.getComponentCount() / 4;
  }
  GridBagConstraints con=new GridBagConstraints(x + 1,y,1,1,0,0,GridBagConstraints.FIRST_LINE_END,GridBagConstraints.NONE,new Insets(4,0,0,4),0,0);
  if (y == 0) {
    con.insets.top=14;
  }
  parent.add(label,con);
  con.gridx++;
  parent.add(widget,con);
}

private void add ( Container parent , String key , JComponent widget , int x , int y ) { JLabel label = new JLabel ( UIManager . getString ( key + "Text" , getLocale ( ) ) ) ; String mnemonic = ( String ) UIManager . get ( key + "Mnemonic" , getLocale ( ) ) ; if ( mnemonic != null ) { try { label . setDisplayedMnemonic ( Integer . parseInt ( mnemonic ) ) ; } catch ( NumberFormatException nfe ) { } String mnemonicIndex = ( String ) UIManager . get ( key + "MnemonicIndex" , getLocale ( ) ) ; if ( mnemonicIndex != null ) { try { label . setDisplayedMnemonicIndex ( Integer . parseInt ( mnemonicIndex ) ) ; } catch ( NumberFormatException nfe ) { } } } label . setLabelFor ( widget ) ; if ( x < 0 ) { x = parent . getComponentCount ( ) % 4 ; } if ( y < 0 ) { y = parent . getComponentCount ( ) / 4 ; } GridBagConstraints con = new GridBagConstraints ( x + 1 , y , 1 , 1 , 0 , 0 , GridBagConstraints . FIRST_LINE_END , GridBagConstraints . NONE , new Insets ( 4 , 0 , 0 , 4 ) , 0 , 0 ) ; if ( y == 0 ) { con . insets . top = 14 ; } parent . add ( label , con ) ; con . gridx ++ ; parent . add ( widget , con ) ; }
adds the widget creating a jlabel with the specified name .
