001: /*
002: * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. 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 Substance Kirill Grouchnikov 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: package test.check;
031:
032: import java.awt.BorderLayout;
033: import java.awt.Color;
034:
035: import javax.swing.*;
036:
037: import com.jgoodies.forms.builder.DefaultFormBuilder;
038: import com.jgoodies.forms.layout.FormLayout;
039:
040: /**
041: * Test application panel for testing components with custom background.
042: *
043: * @author Kirill Grouchnikov
044: */
045: public class ColoredControlsPanel extends JPanel {
046: public ColoredControlsPanel() {
047: this .setLayout(new BorderLayout());
048:
049: FormLayout lm = new FormLayout(
050: "right:pref, 4dlu, left:pref:grow", "");
051: DefaultFormBuilder builder = new DefaultFormBuilder(lm,
052: new ScrollablePanel());
053: builder.setDefaultDialogBorder();
054:
055: JLabel labelOpaque = new JLabel("Sample label");
056: labelOpaque.setOpaque(true);
057: labelOpaque.setForeground(Color.green);
058: labelOpaque.setBackground(Color.red);
059: builder.append("Opaque label", labelOpaque);
060:
061: JLabel labelNonOpaque = new JLabel("Sample label");
062: labelNonOpaque.setOpaque(false);
063: labelNonOpaque.setForeground(Color.green);
064: labelNonOpaque.setBackground(Color.red);
065: builder.append("Non-opaque label", labelNonOpaque);
066:
067: JLabel labelDefault = new JLabel("Sample label");
068: labelDefault.setOpaque(true);
069: labelDefault.setForeground(Color.green);
070: labelDefault.setBackground(Color.red);
071: builder.append("Default label", labelDefault);
072:
073: JCheckBox checkboxOpaque = new JCheckBox("Sample checkbox");
074: checkboxOpaque.setOpaque(true);
075: checkboxOpaque.setForeground(Color.blue);
076: checkboxOpaque.setBackground(Color.yellow);
077: builder.append("Opaque checkbox", checkboxOpaque);
078:
079: JCheckBox checkboxNonOpaque = new JCheckBox("Sample checkbox");
080: checkboxNonOpaque.setOpaque(false);
081: checkboxNonOpaque.setForeground(Color.blue);
082: checkboxNonOpaque.setBackground(Color.yellow);
083: builder.append("Non-opaque checkbox", checkboxNonOpaque);
084:
085: JCheckBox checkboxDefault = new JCheckBox("Sample checkbox");
086: checkboxDefault.setForeground(Color.blue);
087: checkboxDefault.setBackground(Color.yellow);
088: builder.append("Default checkbox", checkboxDefault);
089:
090: JRadioButton radioOpaque = new JRadioButton(
091: "Sample radiobutton");
092: radioOpaque.setOpaque(true);
093: radioOpaque.setForeground(new Color(0, 128, 0));
094: radioOpaque.setBackground(new Color(255, 180, 180));
095: builder.append("Opaque radio", radioOpaque);
096:
097: JRadioButton radioNonOpaque = new JRadioButton(
098: "Sample radiobutton");
099: radioNonOpaque.setOpaque(false);
100: radioNonOpaque.setForeground(new Color(0, 128, 0));
101: radioNonOpaque.setBackground(new Color(255, 180, 180));
102: builder.append("Non-opaque radio", radioNonOpaque);
103:
104: JRadioButton radioDefault = new JRadioButton(
105: "Sample radiobutton");
106: radioDefault.setForeground(new Color(0, 128, 0));
107: radioDefault.setBackground(new Color(255, 180, 180));
108: builder.append("Default radio", radioDefault);
109:
110: JSlider colored3 = new JSlider(100, 1000, 400);
111: colored3.setPaintTicks(true);
112: colored3.setMajorTickSpacing(100);
113: colored3.setForeground(new Color(128, 0, 0));
114: colored3.setBackground(new Color(180, 255, 180));
115: builder.append("Slider", colored3);
116:
117: JPanel colored4 = new JPanel();
118: colored4.setSize(100, 100);
119: colored4.setPreferredSize(colored4.getSize());
120: colored4.setBackground(Color.cyan);
121: builder.append("panel", colored4);
122:
123: JPanel resultPanel = builder.getPanel();
124: resultPanel.setBackground(new Color(200, 200, 255));
125: this .add(new JScrollPane(resultPanel), BorderLayout.CENTER);
126: }
127: }
|