/** * 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); } }