Buggy code:
public class DataComponentPanel extends JPanel { private static int maxComponentCounter = 0 ; private int componentCounter = 0 ; private Controller controller ; private Table table ; private DatabaseAccessor dbaccess ; private GridBagConstraints gridBagConstraints ; private DataComponent prevComponent ; private List < ProgramAlarm > programAlarms ; private List < ProgramRelay > programRelays ; private List < ProgramSystemState > programSystemStates ; private List < DataController > dataControllerList ; public DataComponentPanel ( Controller controller , Program program , List < ProgramAlarm > programAlarms , List < ProgramRelay > programRelays , List < ProgramSystemState > programSystemStates , DatabaseAccessor dbaccess , ComponentOrientation componentOrientation , Table table , List < DataController > dataControllerList ) { } public DataComponentPanel ( Controller controller , Program program , List < ProgramAlarm > programAlarms , List < ProgramRelay > programRelays , List < ProgramSystemState > programSystemStates , DatabaseAccessor dbaccess , ComponentOrientation componentOrientation , Table table , List < DataController > dataControllerList , DataComponent prevComponent ) { } private void intiComponents ( ) { setComponentOrientation ( getComponentOrientation ( ) ) ; gridBagConstraints = createGridBagConstraint ( ) ; JLabel tableTitle = new TableLabel ( ( ( "<html>" + ( table . getUnicodeTitle ( ) ) ) + "<//html>" ) ) ; tableTitle . setOpaque ( true ) ; tableTitle . setBackground ( Color . lightGray ) ; add ( tableTitle , gridBagConstraints ) ; gridBagConstraints . gridwidth = 1 ; try { for ( int i = 0 ; i < ( dataControllerList . size ( ) ) ; i ++ ) { DataController data = dataControllerList . get ( i ) ; DataComponent dataComponent ; if ( ( data . getIsRelay ( ) ) == true ) { for ( ProgramRelay programRelay : programRelays ) { if ( programRelay . getDataId ( ) . equals ( data . getId ( ) ) ) { if ( ( programRelay . getRelayNumber ( ) ) != 0 ) { if ( ( ( data . getValue ( ) ) == null ) || ( ( data . getValue ( ) ) == ( - 1 ) ) ) { programRelay . setOff ( ) ; } else { programRelay . init ( data . getValueToUI ( ) ) ; } dataComponent = ComponentFactory . createRelayComponent ( data , getComponentOrientation ( ) , programRelay ) ; ( gridBagConstraints . gridy ) ++ ; gridBagConstraints . gridx = 0 ; add ( dataComponent . getLabel ( ) , gridBagConstraints ) ; gridBagConstraints . gridx = 1 ; add ( dataComponent . getComponent ( ) , gridBagConstraints ) ; ( componentCounter ) ++ ; } } } } else if ( data . isAlarm ( ) ) { dataComponent = ComponentFactory . createAlarmComponent ( data , getComponentOrientation ( ) , programAlarms ) ; ( gridBagConstraints . gridy ) ++ ; gridBagConstraints . gridx = 0 ; add ( dataComponent . getLabel ( ) , gridBagConstraints ) ; gridBagConstraints . gridx = 1 ; add ( dataComponent . getComponent ( ) , gridBagConstraints ) ; ( componentCounter ) ++ ; } else if ( data . isSystemState ( ) ) { dataComponent = ComponentFactory . createSystemStateComponent ( data , getComponentOrientation ( ) , programSystemStates ) ; ( gridBagConstraints . gridy ) ++ ; gridBagConstraints . gridx = 0 ; add ( dataComponent . getLabel ( ) , gridBagConstraints ) ; <START_BUG> gridBagConstraints . gridx = 1 ; <END_BUG> add ( dataComponent . getComponent ( ) , gridBagConstraints ) ; ( componentCounter ) ++ ; } else { dataComponent = ComponentFactory . createDataComponent ( data , getComponentOrientation ( ) , controller , dbaccess ) ; ( gridBagConstraints . gridy ) ++ ; gridBagConstraints . gridx = 0 ; add ( dataComponent . getLabel ( ) , gridBagConstraints ) ; gridBagConstraints . gridx = 1 ; gridBagConstraints . ipadx = 2 ; add ( dataComponent . getComponent ( ) , gridBagConstraints ) ; ( componentCounter ) ++ ; if ( ( prevComponent ) == null ) { prevComponent = dataComponent ; } else { if ( ( dataComponent . getComponent ( ) ) instanceof DataTextField ) { if ( ( prevComponent . getComponent ( ) ) instanceof DataTextField ) { ( ( DataTextField ) ( prevComponent . getComponent ( ) ) ) . setNextTextField ( ( ( DataTextField ) ( dataComponent . getComponent ( ) ) ) ) ; prevComponent = dataComponent ; } else if ( ( prevComponent . getComponent ( ) ) instanceof DataPasswordField ) { ( ( DataPasswordField ) ( prevComponent . getComponent ( ) ) ) . setNextTextField ( ( ( DataPasswordField ) ( dataComponent . getComponent ( ) ) ) ) ; prevComponent = dataComponent ; } else { prevComponent = dataComponent ; } } if ( ( dataComponent . getComponent ( ) ) instanceof DataPasswordField ) { if ( ( prevComponent . getComponent ( ) ) instanceof DataPasswordField ) { ( ( DataPasswordField ) ( prevComponent . getComponent ( ) ) ) . setNextTextField ( ( ( DataPasswordField ) ( dataComponent . getComponent ( ) ) ) ) ; prevComponent = dataComponent ; } else if ( ( prevComponent . getComponent ( ) ) instanceof DataTextField ) { ( ( DataTextField ) ( prevComponent . getComponent ( ) ) ) . setNextTextField ( ( ( DataTextField ) ( dataComponent . getComponent ( ) ) ) ) ; prevComponent = dataComponent ; } else { prevComponent = dataComponent ; } } } } } calculateMaxComponentCounter ( componentCounter ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } private GridBagConstraints createGridBagConstraint ( ) { } public void fillEmptyComponents ( ) { } public void resetMaxComponentCounter ( ) { } private void calculateMaxComponentCounter ( int componentCounter ) { } public DataComponent getPrevComponent ( ) { } }

Fix:
gridBagConstraints . gridx = 0 ;