Fragment (boolean isPrimaryColumn, int row) { Column column = isPrimaryColumn ? myPrimaryColumn : mySecondaryColumn; if (column.fragments.size() < row) { throw new IllegalStateException("Cannot add text to row " + row + " as in " + (isPrimaryColumn ? "left" : "right") + " column there are " + column.fragments.size() + " rows only"); } Fragment fragment; if (column.fragments.size() == row) { fragment = new Fragment(); if (myFont != null) { fragment.myComponent.setFont(myFont); } column.fragments.add(fragment); } else { fragment = column.fragments.get(row); } return fragment; }