001: /*
002: * Copyright (c) 2002-2004 JGoodies Karsten Lentzsch. All Rights Reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of JGoodies Karsten Lentzsch nor the names of
015: * its contributors may be used to endorse or promote products derived
016: * from this software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030:
031: package com.jgoodies.forms.factories;
032:
033: import javax.swing.JComponent;
034: import javax.swing.JLabel;
035:
036: /**
037: * An interface that defines the factory methods as used by the
038: * {@link com.jgoodies.forms.builder.PanelBuilder} and its subclasses.
039: * <p>
040: *
041: * The texts used in methods <code>#createLabel(String)</code> and
042: * <code>#createTitle(String)</code> can contain an optional mnemonic marker.
043: * The mnemonic and mnemonic index are indicated by a single ampersand (<tt>&</tt>).
044: * For example <tt>"&Save"</tt>, or
045: * <tt>"Save &as"</tt>. To use the ampersand itself
046: * duplicate it, for example <tt>"Look&&Feel"</tt>.
047: *
048: * @author Karsten Lentzsch
049: * @version $Revision: 1.2 $
050: *
051: * @see DefaultComponentFactory
052: * @see com.jgoodies.forms.builder.PanelBuilder
053: */
054:
055: public interface ComponentFactory {
056:
057: /**
058: * Creates and returns a label with an optional mnemonic.
059: * <p>
060: *
061: * <pre>
062: * createLabel("Name"); // No mnemonic
063: * createLabel("N&ame"); // Mnemonic is 'a'
064: * createLabel("Save &as"); // Mnemonic is the second 'a'
065: * createLabel("Look&&Feel"); // No mnemonic, text is Look&Feel
066: * </pre>
067: *
068: * @param textWithMnemonic
069: * the label's text - may contain a mnemonic
070: * @return an label with optional mnemonic
071: */
072: public JLabel createLabel(String textWithMnemonic);
073:
074: /**
075: * Creates and returns a label that uses the foreground color and font of a
076: * <code>TitledBorder</code>.
077: * <p>
078: *
079: * <pre>
080: * createTitle("Name"); // No mnemonic
081: * createTitle("N&ame"); // Mnemonic is 'a'
082: * createTitle("Save &as"); // Mnemonic is the second 'a'
083: * createTitle("Look&&Feel"); // No mnemonic, text is Look&Feel
084: * </pre>
085: *
086: * @param textWithMnemonic
087: * the title's text - may contain a mnemonic
088: * @return an emphasized title label
089: */
090: public JLabel createTitle(String textWithMnemonic);
091:
092: /**
093: * Creates and returns a labeled separator. Useful to separate paragraphs in
094: * a panel, which is often a better choice than a <code>TitledBorder</code>.
095: *
096: * @param text
097: * the title's text
098: * @param alignment
099: * text alignment: left, center, right
100: * @return a title label with separator on the side
101: */
102: public JComponent createSeparator(String text, int alignment);
103:
104: }
|