JGoodies Binding: Feed Bean Example 3

Tuesday, July 7th, 2009

/*
Code revised from Desktop Java Live:
http://www.sourcebeat.com/downloads/
*/

import java.awt.event.ActionEvent;
import java.util.Arrays;
import java.util.List;

import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JToggleButton;

import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.layout.FormLayout;

public class FeedBeanExample3 extends JPanel {
    JTextField nameField;
    JTextField siteField;
    JTextField feedField;
    JComboBox feedTypesComboBox;
    JCheckBox customCheckIntervalCheckbox;
    JTextField intervalField;

    Feed feed;

    public FeedBeanExample3() {
        createFeed();
        DefaultFormBuilder formBuilder = new DefaultFormBuilder(new FormLayout(""));
        formBuilder.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        formBuilder.appendColumn("right:pref");
        formBuilder.appendColumn("3dlu");
        formBuilder.appendColumn("fill:p:g");

        this.nameField = new JTextField();
        formBuilder.append("Name:", this.nameField);
        this.siteField = new JTextField();
        formBuilder.append("Site Url:", this.siteField);
        this.feedField = new JTextField();
        formBuilder.append("Feed Url:", this.feedField);
        this.feedTypesComboBox = new JComboBox(Arrays.asList(new FeedType[]{
                new FeedType("RSS_09"), new FeedType("RSS_093"), new FeedType("RSS_20"), 
        new FeedType("ATOM_03")}).toArray());

        formBuilder.append("Feed Type:", this.feedTypesComboBox);

        CustomCheckIntervalModel customCheckIntervalModel = new CustomCheckIntervalModel(getFeed());
        this.customCheckIntervalCheckbox = new JCheckBox();
        this.customCheckIntervalCheckbox.setModel(customCheckIntervalModel);

        formBuilder.append("Custom Check Interval:", this.customCheckIntervalCheckbox);
        this.intervalField = new JTextField();
        formBuilder.append("Interval:", this.intervalField);

        formBuilder.append(new JButton(new ShowFeedInformationAction()), 3);

        initializeFormElements();

        add(formBuilder.getPanel());
    }

    private void createFeed() {
        this.feed = new Feed();
        this.feed.setName("ClientJava.com");
        this.feed.setSiteUrl("http://www.clientjava.com/blog");
        this.feed.setFeedUrl("http://www.clientjava.com/blog/rss.xml");
        this.feed.setFeedType(new FeedType("RSS_20"));
        this.feed.setCustomCheckIntervalEnabled(true);
        this.feed.setCheckInterval(new Integer(4));
    }

    private void initializeFormElements() {
        this.nameField.setText(this.feed.getName());
        this.siteField.setText(this.feed.getSiteUrl());
        this.feedField.setText(this.feed.getFeedUrl());

        this.feedTypesComboBox.setSelectedItem(this.feed.getFeedType());

        if (this.feed.getCheckInterval() != null) {
            this.intervalField.setText(this.feed.getCheckInterval().toString());
        }
    }

    private void synchFormAndFeed() {
        this.feed.setName(this.nameField.getText());
        this.feed.setSiteUrl(this.siteField.getText());
        this.feed.setFeedUrl(this.feedField.getText());
        this.feed.setFeedType((FeedType) this.feedTypesComboBox.getSelectedItem());
        if (this.feed.isCustomCheckIntervalEnabled()) {
            this.feed.setCheckInterval(new Integer(this.intervalField.getText()));
        } else {
            this.feed.setCheckInterval(null);
        }
    }

    private Feed getFeed() {
        return this.feed;
    }

    private class ShowFeedInformationAction extends AbstractAction {
        public ShowFeedInformationAction() {
            super("Show Feed Information");
        }

        public void actionPerformed(ActionEvent event) {
            synchFormAndFeed();

            StringBuffer message = new StringBuffer();
            message.append("<html>");
            message.append("<b>Name:</b> ");
            message.append(getFeed().getName());
            message.append("<br>");
            message.append("<b>Site URL:</b> ");
            message.append(getFeed().getSiteUrl());
            message.append("<br>");
            message.append("<b>Feed URL:</b> ");
            message.append(getFeed().getFeedUrl());
            message.append("<br>");
            message.append("<b>Feed Type:</b> ");
            message.append(getFeed().getFeedType());
            message.append("<br>");
            message.append("<b>Custom Check:</b> ");
            message.append(getFeed().isCustomCheckIntervalEnabled());
            message.append("<br>");
            message.append("<b>Check Interval:</b> ");
            message.append(getFeed().getCheckInterval());
            message.append("</html>");

            JOptionPane.showMessageDialog(null, message.toString());
        }
    }

    private class CustomCheckIntervalModel extends JToggleButton.ToggleButtonModel {
        private Feed feed;

        public CustomCheckIntervalModel(Feed feed) {
            super();
            this.feed = feed;
        }

        public boolean isSelected() {
            return feed.isCustomCheckIntervalEnabled();
        }

        public void setSelected(boolean b) {
            feed.setCustomCheckIntervalEnabled(b);
        }
    }
    
    public static void main(String[] a){
      JFrame f = new JFrame("Feed Bean Example 3");
      f.setDefaultCloseOperation(2);
      f.add(new FeedBeanExample3());
      f.pack();
      f.setVisible(true);
    }
    class Feed {
        private long id = 0;
        private String name;
        private String siteUrl;
        private String feedUrl;
        private FeedType feedType;
        private boolean customCheckIntervalEnabled = false;
        private Integer checkInterval;

        public Feed() {
        }

        public Feed(String name, String siteUrl, String feedUrl, FeedType feedType) {
            this.name = name;
            this.siteUrl = siteUrl;
            this.feedUrl = feedUrl;
            this.feedType = feedType;
        }

        public long getId() {
            return id;
        }

        public void setId(long id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String newName) {
            this.name = newName;
        }

        public String getSiteUrl() {
            return siteUrl;
        }

        public void setSiteUrl(String newSiteUrl) {
            this.siteUrl = newSiteUrl;
        }

        public String getFeedUrl() {
            return feedUrl;
        }

        public void setFeedUrl(String newFeedUrl) {
            this.feedUrl = newFeedUrl;
        }

        public FeedType getFeedType() {
            return feedType;
        }

        public void setFeedType(FeedType newFeedType) {
            this.feedType = newFeedType;
        }

        public boolean isCustomCheckIntervalEnabled() {
            return customCheckIntervalEnabled;
        }

        public void setCustomCheckIntervalEnabled(boolean newCustomCheckIntervalEnabled) {
            this.customCheckIntervalEnabled = newCustomCheckIntervalEnabled;
        }

        public Integer getCheckInterval() {
            return checkInterval;
        }

        public void setCheckInterval(Integer newCheckInterval) {
            this.checkInterval = newCheckInterval;
        }

        public String toString() {
            return this.name;
        }
    }

    class FeedType {
        private String type;

        private FeedType(String type) {
            this.type = type;
        }

        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof FeedType)) return false;

            final FeedType feedType = (FeedType) o;

            if (type != null ? !type.equals(feedType.type) : feedType.type != null) return false;

            return true;
        }

        public int hashCode() {
            return (type != null ? type.hashCode() : 0);
        }

        public String toString() {
            return this.type;
        }
    }
    
}

           
       

ItemChooser

Tuesday, June 30th, 2009

/*
 * Copyright (c) 2000 David Flanagan.  All rights reserved.
 * This code is from the book Java Examples in a Nutshell, 2nd Edition.
 * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied.
 * You may study, use, and modify it for any non-commercial purpose.
 * You may distribute it non-commercially as long as you retain this notice.
 * For a commercial use license, or to purchase the book (recommended),
 * visit http://www.davidflanagan.com/javaexamples2.
 */

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Iterator;

import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
 * This class is a Swing component that presents a choice to the user. It allows
 * the choice to be presented in a JList, in a JComboBox, or with a bordered
 * group of JRadioButton components. Additionally, it displays the name of the
 * choice with a JLabel. It allows an arbitrary value to be associated with each
 * possible choice. Note that this component only allows one item to be selected
 * at a time. Multiple selections are not supported.
 */
public class ItemChooser extends JPanel {
  // These fields hold property values for this component
  String name; // The overall name of the choice

  String[] labels; // The text for each choice option

  Object[] values; // Arbitrary values associated with each option

  int selection; // The selected choice

  int presentation; // How the choice is presented

  // These are the legal values for the presentation field
  public static final int LIST = 1;

  public static final int COMBOBOX = 2;

  public static final int RADIOBUTTONS = 3;

  // These components are used for each of the 3 possible presentations
  JList list; // One type of presentation

  JComboBox combobox; // Another type of presentation

  JRadioButton[] radiobuttons; // Yet another type

  // The list of objects that are interested in our state
  ArrayList listeners = new ArrayList();

  // The constructor method sets everything up
  public ItemChooser(String name, String[] labels, Object[] values,
      int defaultSelection, int presentation) {
    // Copy the constructor arguments to instance fields
    this.name = name;
    this.labels = labels;
    this.values = values;
    this.selection = defaultSelection;
    this.presentation = presentation;

    // If no values were supplied, use the labels
    if (values == null)
      this.values = labels;

    // Now create content and event handlers based on presentation type
    switch (presentation) {
    case LIST:
      initList();
      break;
    case COMBOBOX:
      initComboBox();
      break;
    case RADIOBUTTONS:
      initRadioButtons();
      break;
    }
  }

  // Initialization for JList presentation
  void initList() {
    list = new JList(labels); // Create the list
    list.setSelectedIndex(selection); // Set initial state

    // Handle state changes
    list.addListSelectionListener(new ListSelectionListener() {
      public void valueChanged(ListSelectionEvent e) {
        ItemChooser.this.select(list.getSelectedIndex());
      }
    });

    // Lay out list and name label vertically
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // vertical
    this.add(new JLabel(name)); // Display choice name
    this.add(new JScrollPane(list)); // Add the JList
  }

  // Initialization for JComboBox presentation
  void initComboBox() {
    combobox = new JComboBox(labels); // Create the combo box
//    combobox.setSelectedIndex(selection); // Set initial state

    // Handle changes to the state
    combobox.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent e) {
        ItemChooser.this.select(combobox.getSelectedIndex());
      }
    });

    // Lay out combo box and name label horizontally
    this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    this.add(new JLabel(name));
    this.add(combobox);
  }

  // Initialization for JRadioButton presentation
  void initRadioButtons() {
    // Create an array of mutually exclusive radio buttons
    radiobuttons = new JRadioButton[labels.length]; // the array
    ButtonGroup radioButtonGroup = new ButtonGroup(); // used for exclusion
    ChangeListener listener = new ChangeListener() { // A shared listener
      public void stateChanged(ChangeEvent e) {
        JRadioButton b = (JRadioButton) e.getSource();
        if (b.isSelected()) {
          // If we received this event because a button was
          // selected, then loop through the list of buttons to
          // figure out the index of the selected one.
          for (int i = 0; i < radiobuttons.length; i++) {
            if (radiobuttons[i] == b) {
              ItemChooser.this.select(i);
              return;
            }
          }
        }
      }
    };

    // Display the choice name in a border around the buttons
    this.setBorder(new TitledBorder(new EtchedBorder(), name));
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    // Create the buttons, add them to the button group, and specify
    // the event listener for each one.
    for (int i = 0; i < labels.length; i++) {
      radiobuttons[i] = new JRadioButton(labels[i]);
      if (i == selection)
        radiobuttons[i].setSelected(true);
      radiobuttons[i].addChangeListener(listener);
      radioButtonGroup.add(radiobuttons[i]);
      this.add(radiobuttons[i]);
    }
  }

  // These simple property accessor methods just return field values
  // These are read-only properties. The values are set by the constructor
  // and may not be changed.
  public String getName() {
    return name;
  }

  public int getPresentation() {
    return presentation;
  }

  public String[] getLabels() {
    return labels;
  }

  public Object[] getValues() {
    return values;
  }

  /** Return the index of the selected item */
  public int getSelectedIndex() {
    return selection;
  }

  /** Return the object associated with the selected item */
  public Object getSelectedValue() {
    return values[selection];
  }

  /**
   * Set the selected item by specifying its index. Calling this method
   * changes the on-screen display but does not generate events.
   */
  public void setSelectedIndex(int selection) {
    switch (presentation) {
    case LIST:
      list.setSelectedIndex(selection);
      break;
    case COMBOBOX:
      combobox.setSelectedIndex(selection);
      break;
    case RADIOBUTTONS:
      radiobuttons[selection].setSelected(true);
      break;
    }
    this.selection = selection;
  }

  /**
   * This internal method is called when the selection changes. It stores the
   * new selected index, and fires events to any registered listeners. The
   * event listeners registered on the JList, JComboBox, or JRadioButtons all
   * call this method.
   */
  protected void select(int selection) {
    this.selection = selection; // Store the new selected index
    if (!listeners.isEmpty()) { // If there are any listeners registered
      // Create an event object to describe the selection
      ItemChooser.Event e = new ItemChooser.Event(this, selection,
          values[selection]);
      // Loop through the listeners using an Iterator
      for (Iterator i = listeners.iterator(); i.hasNext();) {
        ItemChooser.Listener l = (ItemChooser.Listener) i.next();
        l.itemChosen(e); // Notify each listener of the selection
      }
    }
  }

  // These methods are for event listener registration and deregistration
  public void addItemChooserListener(ItemChooser.Listener l) {
    listeners.add(l);
  }

  public void removeItemChooserListener(ItemChooser.Listener l) {
    listeners.remove(l);
  }

  /**
   * This inner class defines the event type generated by ItemChooser objects
   * The inner class name is Event, so the full name is ItemChooser.Event
   */
  public static class Event extends java.util.EventObject {
    int selectedIndex; // index of the selected item

    Object selectedValue; // the value associated with it

    public Event(ItemChooser source, int selectedIndex, Object selectedValue) {
      super(source);
      this.selectedIndex = selectedIndex;
      this.selectedValue = selectedValue;
    }

    public ItemChooser getItemChooser() {
      return (ItemChooser) getSource();
    }

    public int getSelectedIndex() {
      return selectedIndex;
    }

    public Object getSelectedValue() {
      return selectedValue;
    }
  }

  /**
   * This inner interface must be implemented by any object that wants to be
   * notified when the current selection in a ItemChooser component changes.
   */
  public interface Listener extends java.util.EventListener {
    public void itemChosen(ItemChooser.Event e);
  }

  public static void main(String[] args) {
    // Create a window, arrange to handle close requests
    final JFrame frame = new JFrame("ItemChooser Demo");
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });

    // A "message line" to display results in
    final JLabel msgline = new JLabel(" ");
    args = new String[]{"a","b","c"};
    // Create a panel holding three ItemChooser components
    JPanel chooserPanel = new JPanel();
    final ItemChooser c1 = new ItemChooser("Choice #1", args, null, 0,
        ItemChooser.LIST);
    final ItemChooser c2 = new ItemChooser("Choice #2", args, null, 0,
        ItemChooser.COMBOBOX);
    final ItemChooser c3 = new ItemChooser("Choice #3", args, null, 0,
        ItemChooser.RADIOBUTTONS);

    // An event listener that displays changes on the message line
    ItemChooser.Listener l = new ItemChooser.Listener() {
      public void itemChosen(ItemChooser.Event e) {
        msgline.setText(e.getItemChooser().getName() + ": "
            + e.getSelectedIndex() + ": " + e.getSelectedValue());
      }
    };
    c1.addItemChooserListener(l);
    c2.addItemChooserListener(l);
    c3.addItemChooserListener(l);

    // Instead of tracking every change with a ItemChooser.Listener,
    // applications can also just query the current state when
    // they need it. Here’s a button that does that.
    JButton report = new JButton("Report");
    report.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // Note the use of multi-line italic HTML text
        // with the JOptionPane message dialog box.
        String msg = "<html><i>" + c1.getName() + ": "
            + c1.getSelectedValue() + "<br>" + c2.getName() + ": "
            + c2.getSelectedValue() + "<br>" + c3.getName() + ": "
            + c3.getSelectedValue() + "</i>";
        JOptionPane.showMessageDialog(frame, msg);
      }
    });

    // Add the 3 ItemChooser objects, and the Button to the panel
    chooserPanel.add(c1);
    chooserPanel.add(c2);
    chooserPanel.add(c3);
    chooserPanel.add(report);

    // Add the panel and the message line to the window
    Container contentPane = frame.getContentPane();
    contentPane.add(chooserPanel, BorderLayout.CENTER);
    contentPane.add(msgline, BorderLayout.SOUTH);

    // Set the window size and pop it up.
    frame.pack();
    frame.show();
  }

}

           
       

The main class of the JGoodies Tiny application

Thursday, June 25th, 2009

/*
 * Copyright (c) 2001-2005 JGoodies Karsten Lentzsch. All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions are met:
 * 
 *  o Redistributions of source code must retain the above copyright notice, 
 *    this list of conditions and the following disclaimer. 
 *     
 *  o Redistributions in binary form must reproduce the above copyright notice, 
 *    this list of conditions and the following disclaimer in the documentation 
 *    and/or other materials provided with the distribution. 
 *     
 *  o Neither the name of JGoodies Karsten Lentzsch nor the names of 
 *    its contributors may be used to endorse or promote products derived 
 *    from this software without specific prior written permission. 
 *     
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;

import javax.swing.*;
import javax.swing.border.EmptyBorder;

import com.jgoodies.looks.FontSizeHints;
import com.jgoodies.looks.LookUtils;
import com.jgoodies.looks.Options;

/**
 * The main class of the JGoodies Tiny application. 
 * It configures the UI, builds the main frame and opens it.
 * <p>
 * The JGoodies Looks Professional comes with Skeleton, a much better sample
 * application that separates concerns and uses a scalable architecture.
 *
 * @author Karsten Lentzsch
 */
public class Tiny {

    /**
     * Configures the UI, then builds and opens the UI.
     */
    public static void main(String[] args) {
        Tiny instance = new Tiny();
        instance.configureUI();
        instance.buildInterface();
    }

    /**
     * Configures the UI; tries to set the system look on Mac, 
     * <code>WindowsLookAndFeel</code> on general Windows, and
     * <code>Plastic3DLookAndFeel</code> on Windows XP and all other OS.<p>
     * 
     * The JGoodies Swing Suite’s <code>ApplicationStarter</code>,
     * <code>ExtUIManager</code>, and <code>LookChoiceStrategies</code>
     * classes provide a much more fine grained algorithm to choose and
     * restore a look and theme.
     */
    private void configureUI() {
        UIManager.put(Options.USE_SYSTEM_FONTS_APP_KEY, Boolean.TRUE);
        Options.setGlobalFontSizeHints(FontSizeHints.MIXED);
        Options.setDefaultIconSize(new Dimension(18, 18));

        String lafName =
            LookUtils.IS_OS_WINDOWS_XP
                ? Options.getCrossPlatformLookAndFeelClassName()
                : Options.getSystemLookAndFeelClassName();

        try {
            UIManager.setLookAndFeel(lafName);
        } catch (Exception e) {
            System.err.println("Can’t set look & feel:" + e);
        }
    }

    /**
     * Creates and configures a frame, builds the menu bar, builds the
     * content, locates the frame on the screen, and finally shows the frame.
     */
    private void buildInterface() {
        JFrame frame = new JFrame();
        frame.setJMenuBar(buildMenuBar());
        frame.setContentPane(buildContentPane());
        frame.setSize(600, 400);
        locateOnScreen(frame);
        frame.setTitle("JGoodies :: Tiny");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

    /**
     * Locates the frame on the screen center.
     */
    private void locateOnScreen(Frame frame) {
        Dimension paneSize   = frame.getSize();
        Dimension screenSize = frame.getToolkit().getScreenSize();
        frame.setLocation(
            (screenSize.width  - paneSize.width)  / 2,
            (screenSize.height - paneSize.height) / 2);
    }

    /**
     * Builds and answers the menu bar.
     */
    private JMenuBar buildMenuBar() {
        JMenu menu;
        JMenuBar menuBar = new JMenuBar();
        menuBar.putClientProperty(Options.HEADER_STYLE_KEY, Boolean.TRUE);

        menu = new JMenu("File");
        menu.add(new JMenuItem("New…"));
        menu.add(new JMenuItem("Open…"));
        menu.add(new JMenuItem("Save"));
        menu.addSeparator();
        menu.add(new JMenuItem("Print…"));
        menuBar.add(menu);

        menu = new JMenu("Edit");
        menu.add(new JMenuItem("Cut"));
        menu.add(new JMenuItem("Copy"));
        menu.add(new JMenuItem("Paste"));
        menuBar.add(menu);

        return menuBar;
    }

    /**
     * Builds and answers the content pane.
     */
    private JComponent buildContentPane() {
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(buildToolBar(), BorderLayout.NORTH);
        panel.add(buildSplitPane(), BorderLayout.CENTER);
        panel.add(buildStatusBar(), BorderLayout.SOUTH);
        return panel;
    }

    /**
     * Builds and answers the tool bar.
     */
    private Component buildToolBar() {
        JToolBar toolBar = new JToolBar();
        toolBar.putClientProperty(Options.HEADER_STYLE_KEY, Boolean.TRUE);
        
        toolBar.add(createCenteredLabel("Tool Bar"));
        return toolBar;
    }

    /**
     * Builds and answers the split panel.
     */
    private Component buildSplitPane() {
        JSplitPane splitPane =
            new JSplitPane(
                JSplitPane.HORIZONTAL_SPLIT,
                buildSideBar(),
                buildMainPanel());
        return splitPane;
    }

    /**
     * Builds and answers the side bar.
     */
    private Component buildSideBar() {
        return createStrippedScrollPane(new JTree());
    }

    /**
     * Builds and answers the main panel.
     */
    private Component buildMainPanel() {
        JEditorPane editor = new JEditorPane();
        editor.setText(
            "This is a minimal Swing application, that demos,\n" +
            "how to install and use a JGoodies look&feel\n" +
            "in a Swing application.");
        return createStrippedScrollPane(editor);
    }

    /**
     * Builds and answers the tool bar.
     */
    private Component buildStatusBar() {
        JPanel statusBar = new JPanel(new BorderLayout());
        statusBar.add(createCenteredLabel("Status Bar"));
        return statusBar;
    }

    // Helper Code ********************************************************

    /**
     * Creates and answers a <code>JScrollpane</code> that has no border.
     */
    private JScrollPane createStrippedScrollPane(Component c) {
        JScrollPane scrollPane = new JScrollPane(c);
        scrollPane.setBorder(null);
        return scrollPane;
    }

    /**
     * Creates and answers a <code>JLabel</code> that has the text
     * centered and that is wrapped with an empty border.
     */
    private Component createCenteredLabel(String text) {
        JLabel label = new JLabel(text);
        label.setHorizontalAlignment(SwingConstants.CENTER);
        label.setBorder(new EmptyBorder(3, 3, 3, 3));
        return label;
    }

}