code: @Override
      public void componentResized(ComponentEvent event) {
          final int SIZE = getWidth() < getHeight() ? getWidth() : getHeight();
          setPreferredSize(new java.awt.Dimension(SIZE, SIZE));
  
          if (SIZE < getMinimumSize().width || SIZE < getMinimumSize().height) {
              setPreferredSize(getMinimumSize());
          }
          calcInnerBounds();
  
          init(INNER_BOUNDS.width, INNER_BOUNDS.height);
  
          //revalidate();
          //repaint();
      }
docs: <editor-fold defaultstate="collapsed" desc="ComponentListener">