/**
   * Initializes this window.
   *
   * @param window the component which represents the window. This component will be used when
   *     calling methods like {@link #setWindowBounds(Rectangle, boolean)}. It is the root of this
   *     whole window.
   * @param contentParent the container which will be used as parent for the contents of this
   *     window. This method will change the {@link LayoutManager} and add a child to <code>
   *     contentParent</code>. This component can be the same as <code>window</code>.
   * @param borderAllowed If <code>true</code> and if {@link WindowConfiguration#isResizeable()},
   *     then a new border is installed for the {@link #getDisplayerParent() displayer parent}, and
   *     some {@link MouseListener}s are installed. When the mouse is over the border it will change
   *     the cursor and the user can resize or move the window. If <code>false</code> nothing
   *     happens and the resizing system has to be implemented by the subclass.
   */
  protected void init(
      Component window,
      Container contentParent,
      WindowConfiguration configuration,
      boolean borderAllowed) {
    if (window == null) throw new IllegalArgumentException("window must not be null");

    if (contentParent == null) throw new IllegalArgumentException("contentParent must not be null");

    this.window = window;

    content = createContent(configuration);
    content.setController(getController());
    if (configuration.isResizeable()) {
      contentParent.setLayout(new GridLayout(1, 1));
    } else {
      contentParent.setLayout(new ResizingLayoutManager(this, window));
    }
    contentParent.add(content);

    Container parent = getDisplayerParent();
    parent.setLayout(new GridLayout(1, 1));

    if (configuration.isResizeable() && borderAllowed) {
      if (parent instanceof JComponent && configuration.getBorderFactory() != null) {
        border = configuration.getBorderFactory().create(this, (JComponent) parent);
        border.setController(getController());
        borderModifier = new WindowBorder((JComponent) parent);
        borderModifier.setBorder(border);
        borderModifier.setController(getController());

        ((JComponent) parent).setBorder(border);
      }

      Listener listener = new Listener();
      parent.addMouseListener(listener);
      parent.addMouseMotionListener(listener);
      parent.addComponentListener(listener);
    }

    window.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent e) {
            fireShapeChanged();
          }

          @Override
          public void componentMoved(ComponentEvent e) {
            fireShapeChanged();
          }
        });

    addScreenDockWindowListener(windowListener);
  }
 @Override
 public void setController(DockController controller) {
   super.setController(controller);
   content.setController(controller);
   if (border != null) {
     border.setController(controller);
   }
   if (borderModifier != null) {
     borderModifier.setController(controller);
   }
 }
 /**
  * Gets the container on which the displayer is shown.
  *
  * @return the parent of the displayer
  */
 protected Container getDisplayerParent() {
   return content.getContentPane();
 }
  /**
   * Creates the component that will be used as {@link JDialog#setContentPane(Container)
   * content-pane}. This method is invoked by the constructor.
   *
   * @param configuration the configuration of this window
   * @return the new content pane
   */
  protected SecureContainer createContent(WindowConfiguration configuration) {
    if (configuration.isTransparent()) {
      contentBackground =
          new BackgroundPanel(Transparency.TRANSPARENT) {
            @Override
            protected void configure(Transparency transparency) {
              setTransparency(transparency);
            }
          };
    } else {
      contentBackground =
          new BackgroundPanel(Transparency.DEFAULT) {
            @Override
            protected void configure(Transparency transparency) {
              // does not support transparency as this is a root component
            }
          };
    }
    contentBackground.setBackground(background);

    SecureContainer panel =
        new SecureContainer() {
          @Override
          protected void paintOverlay(Graphics g) {
            boolean removal = AbstractScreenDockWindow.this.removal;
            if (isMoveOnTitleGrab()) {
              removal = false;
            }

            if (combination != null || removal) {
              ScreenDockStation station = getStation();
              StationPaint paint = station.getPaint().get();
              if (paint != null) {
                Insets insets = getInsets();

                Rectangle bounds = new Rectangle(0, 0, getWidth(), getHeight());
                Rectangle insert =
                    new Rectangle(
                        2 * insets.left,
                        2 * insets.top,
                        getWidth() - 2 * (insets.left + insets.right),
                        getHeight() - 2 * (insets.top + insets.bottom));

                if (combination != null) {
                  combination.paint(g, contentBackground, paint, bounds, insert);
                } else if (removal) {
                  paint.drawRemoval(g, station, bounds, insert);
                }
              }
            }
          }
        };

    if (configuration.isTransparent()) {
      panel.setSolid(false);
    }
    panel.setContentPane(contentBackground);
    panel
        .getBasePane()
        .setLayout(
            new BorderLayout() {
              private Dimension lastMinimumSize;

              @Override
              public void layoutContainer(Container target) {
                Dimension minimumSize = minimumLayoutSize(target);
                if (lastMinimumSize == null || !lastMinimumSize.equals(minimumSize)) {
                  lastMinimumSize = minimumSize;
                  checkWindowBounds();
                }
                super.layoutContainer(target);
              }
            });
    panel.getBasePane().add(contentBackground, BorderLayout.CENTER);

    return panel;
  }