001: /*
002: * Copyright (c) 2001-2007 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.looks.demo;
032:
033: import javax.swing.JButton;
034: import javax.swing.JCheckBox;
035: import javax.swing.JComboBox;
036: import javax.swing.JComponent;
037: import javax.swing.JLabel;
038: import javax.swing.JRadioButton;
039: import javax.swing.JToggleButton;
040:
041: import com.jgoodies.forms.builder.PanelBuilder;
042: import com.jgoodies.forms.factories.Borders;
043: import com.jgoodies.forms.layout.CellConstraints;
044: import com.jgoodies.forms.layout.FormLayout;
045:
046: /**
047: * Contains a bunch of components with HTML labels.
048: *
049: * @author Karsten Lentzsch
050: * @version $Revision: 1.6 $
051: */
052: final class HtmlTab {
053:
054: private static final String HTML_TEXT = "<html><b>Bold</b>, <i>Italics</i>, <tt>Typewriter</tt></html>";
055:
056: private JButton button;
057: private JToggleButton toggleButton;
058: private JComboBox comboBox;
059: private JRadioButton radioButton;
060: private JCheckBox checkBox;
061: private JLabel label;
062:
063: /**
064: * Creates and configures the UI components.
065: */
066: private void initComponents() {
067: button = new JButton(HTML_TEXT);
068: toggleButton = new JToggleButton(HTML_TEXT);
069: radioButton = new JRadioButton(HTML_TEXT);
070: radioButton.setContentAreaFilled(false);
071: label = new JLabel(HTML_TEXT);
072: checkBox = new JCheckBox(HTML_TEXT);
073: checkBox.setContentAreaFilled(false);
074: comboBox = new JComboBox(new String[] { HTML_TEXT, "Two",
075: "Three" });
076: }
077:
078: /**
079: * Builds the panel.
080: */
081: JComponent build() {
082: initComponents();
083:
084: FormLayout layout = new FormLayout(
085: "0:grow, right:pref, 6dlu, pref, pref, 0:grow",
086: "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p");
087: layout.setColumnGroups(new int[][] { { 2, 5 } });
088: PanelBuilder builder = new PanelBuilder(layout);
089: builder.setBorder(Borders.DLU14_BORDER);
090: builder.getPanel().setOpaque(false);
091:
092: CellConstraints cc = new CellConstraints();
093: builder.addLabel("Label:", cc.xy(2, 1));
094: builder.add(label, cc.xy(4, 1));
095: builder.addLabel("Radio:", cc.xy(2, 3));
096: builder.add(radioButton, cc.xy(4, 3));
097: builder.addLabel("Check:", cc.xy(2, 5));
098: builder.add(checkBox, cc.xy(4, 5));
099: builder.addLabel("Button:", cc.xy(2, 7));
100: builder.add(button, cc.xy(4, 7));
101: builder.addLabel("Toggle:", cc.xy(2, 9));
102: builder.add(toggleButton, cc.xy(4, 9));
103: builder.addLabel("Combo:", cc.xy(2, 11));
104: builder.add(comboBox, cc.xy(4, 11));
105: return builder.getPanel();
106: }
107:
108: }
|