@Override protected void setBackground(BackgroundAlgorithm background) { this.background = background; if (contentBackground != null) { contentBackground.setBackground(background); } window.repaint(); }
/** * 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; }