@Override
  public Dimension getPreferredSize(JComponent c) {
    Dimension size = super.getPreferredSize(c);
    if (size != null) {

      JTextComponent component = getComponent();
      int columns = component instanceof JTextField ? ((JTextField)component).getColumns() : 0;
      if (columns != 0) {
        Insets insets = component.getInsets();

        FontMetrics fm = component.getFontMetrics(component.getFont());
        size.width = columns * fm.charWidth('m') + insets.left + insets.right;
      }

      updatePreferredSize(component, size);
    }

    return size;
  }
@Override
  public Dimension getPreferredSize(JComponent c)