/**
   * Applies properties from a theme to tabbed panel and all the titled tabs.
   *
   * @param theme theme to apply
   */
  private void applyTheme(TabbedPanelTitledTabTheme theme) {
    // Remove the previous theme. If we hadn't added the DefaultTheme the
    // first time we wouldn't have any theme to remove and thus we would
    // have had to implement a flag or theme reference to tell us if we
    // needed to remove a theme or not.
    tabbedPanel.getProperties().removeSuperObject(activeTheme.getTabbedPanelProperties());
    titledTabProperties.removeSuperObject(activeTheme.getTitledTabProperties());

    // Adding a super object means that any properties that are set in the
    // super
    // object will be used instead of the same properties in the default
    // properties. Note that if you have explicitly set a property, for
    // example setTabAreaOrientation in the properties for the tabbed
    // panel, then that property will not be affected by the super object
    // i.e. it will still return the same value after adding the super
    // object.
    tabbedPanel.getProperties().addSuperObject(theme.getTabbedPanelProperties());
    titledTabProperties.addSuperObject(theme.getTitledTabProperties());

    activeTheme = theme;
  }
  /** Constructor */
  private SimpleTabbedPanelExample() {
    frame.setSize(600, 400);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(createMenuBar());
    frame.getContentPane().add(tabbedPanel, BorderLayout.CENTER);

    // Set the "close all tabs" button as a tab area component
    tabbedPanel.setTabAreaComponents(new JComponent[] {createCloseAllTabsButton(tabbedPanel)});

    // Create 6 titled tabs and add them to the tabbed panel
    for (int i = 0; i < 6; i++) tabbedPanel.addTab(createTab());

    // Apply the default theme
    tabbedPanel.getProperties().addSuperObject(themes[0].getTabbedPanelProperties());
    titledTabProperties.addSuperObject(themes[0].getTitledTabProperties());
    activeTheme = themes[0];

    frame.setVisible(true);
  }