private static void checkEmptyCells(RadContainer container) {
    JComponent jComponent = container.getDelegee();
    GridBagLayout layout = (GridBagLayout)jComponent.getLayout();
    Dimension oldSize = jComponent.getSize();

    // clear cells
    layout.columnWidths = null;
    layout.rowHeights = null;

    // calculate layout fields
    jComponent.setSize(500, 400);
    jComponent.doLayout();
    jComponent.setSize(oldSize);

    int[][] dimensions = layout.getLayoutDimensions();

    // check empty columns
    int[] columnWidths = dimensions[0];
    boolean doLayoutColumns = false;

    for (int i = 0; i < columnWidths.length; i++) {
      if (columnWidths[i] == 0) {
        columnWidths[i] = MINIMUM_GRID_SIZE;
        doLayoutColumns = true;
      }
    }

    // check empty rows
    int[] rowHeights = dimensions[1];
    boolean doLayoutRows = false;

    for (int i = 0; i < rowHeights.length; i++) {
      if (rowHeights[i] == 0) {
        rowHeights[i] = MINIMUM_GRID_SIZE;
        doLayoutRows = true;
      }
    }

    // apply changes
    if (doLayoutColumns) {
      layout.columnWidths = columnWidths;
    }
    if (doLayoutRows) {
      layout.rowHeights = rowHeights;
    }
    if (doLayoutColumns || doLayoutRows) {
      jComponent.doLayout();
    }
  }
private static void checkEmptyCells(RadContainer container)