code: @Override
      public void componentResized(ComponentEvent event) {
          final int SIZE = getWidth() <= getHeight() ? getWidth() : getHeight();
          final Container PARENT = getParent();
          if ((PARENT != null) && (PARENT.getLayout() == null)) {
              if (SIZE < getMinimumSize().width || SIZE < getMinimumSize().height) {
                  setSize(getMinimumSize());
              } else {
                  setSize(SIZE, SIZE);
              }
          } else {
              if (SIZE < getMinimumSize().width || SIZE < getMinimumSize().height) {
                  setSize(getMinimumSize());
                  setPreferredSize(getMinimumSize());
              } else {
                  setSize(new Dimension(SIZE, SIZE));
                  setPreferredSize(new Dimension(SIZE, SIZE));
              }
          }
  
          calcInnerBounds();
  
          recreateLedImages();
          if (isLedOn()) {
              setCurrentLedImage(getLedImageOn());
          } else {
              setCurrentLedImage(getLedImageOff());
          }
  
          recreateUserLedImages();
          if (isUserLedOn()) {
              setCurrentUserLedImage(getUserLedImageOn());
          } else {
              setCurrentUserLedImage(getUserLedImageOff());
          }
  
          getModel().setSize(getLocation().x, getLocation().y, SIZE, SIZE);
          init(getInnerBounds().width, getInnerBounds().height);
      }
docs: <editor-fold defaultstate="collapsed" desc="ComponentListener">