Window Decoration, Part 4 - Logo Renderer and More(17:34, 31. Mar. 2010)

Sometimes it's necessary to emphasize your corporate identity (CI) in your application. This article describes how to put your logo into the title pane and completes our technical article series about Synthetica's window decoration.

To display a logo in the title panel Synthetica provides the SyntheticaLogoRenderer interface. The returned component is responsible for logo rendering - a typical implementation returns a JLabel instance just like in the example below.

import de.javasoft.plaf.synthetica.SyntheticaLogoRenderer;

class MyLogoRenderer extends JLabel implements SyntheticaLogoRenderer
{
  public JComponent getRendererComponent(JRootPane root, boolean windowIsActive)
  {
    return this;
  }
} 

In your apllication the renderer has to be passed to your rootPane by the client propery Synthetica.logoRenderer.

MyLogoRenderer logoRenderer = new MyLogoRenderer();
logoRenderer.setHorizontalAlignment(SwingConstants.CENTER);
logoRenderer.setIcon(loadIcon("logo.png"));
frame.getRootPane().putClientProperty("Synthetica.logoRenderer", logoRenderer);

logoRenderer

If possible the renderer is spaned across the title pane and the menuBar. However, this is only supported if the menuBar component is transparent. Because of this, for most themes Synthetica uses only the title panel for logo rendering. You can also set the client property Synthetica.logoRenderer.titlePaneOnly to force Synthetica to use the title panel only.

frame.getRootPane().putClientProperty("Synthetica.logoRenderer.titlePaneOnly", true); 
frame.getRootPane().putClientProperty("Synthetica.logoRenderer.respectButtons", true);

The client property Synthetica.logoRenderer.respectButtons defines if the title panel controls should be respected for calculating the logo position. In case that you also want to add a title text, you can simply configure your renderer like a regular label component.

LogoRenderer renderer = new LogoRenderer();
renderer.setHorizontalAlignment(SwingConstants.CENTER);
renderer.setIcon(loadIcon("logo2.png"));
renderer.setText("App-Title");
renderer.setForeground(new Color(0x40CC40));
renderer.setFont(renderer.getFont().deriveFont(Font.BOLD));
renderer.setHorizontalTextPosition(SwingUtilities.CENTER);
renderer.setVerticalTextPosition(SwingUtilities.BOTTOM);
renderer.setIconTextGap(0);
getRootPane().putClientProperty("Synthetica.logoRenderer", renderer);

LogoRenderer With Title

If you want to see a logo renderer in action feel free to take a look at our Paint demo application.

Minimum Window Size

As you maybe know Synthetica respects the minimum size of your window components while resizing. This means that you can not resize your windows below the minimum size, required by visible window components. However, if you want to disable this behavior you can specify a custom minimum size.

UIManager.setLookAndFeel("de.javasoft.plaf.synthetica.SyntheticaBlackEyeLookAndFeel");
UIManager.put("Synthetica.rootPane.minimumWindowSize", new Dimension(100,100));

Additional UI-properties can be found in the RootPane section of Synthetica's customization list.

Related Posts

Window Decoration, Part 1 - Basics and Title Pane
Window Decoration, Part 2 - Non-Rectangular Window Shapes
Window Decoration, Part 3 - Custom Decoration for Dialogs