/** * Copyright © 2006, 2007 Roberto Mariottini. All rights reserved. * * Permission is granted to anyone to use this software in source and binary forms * for any purpose, with or without modification, including commercial applications, * and to alter it and redistribute it freely, 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 The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * o Altered source versions must be plainly marked as such, and must not * be misrepresented as being the original software. * * 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.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import net.mariottini.swing.JColorComboBox; public final class JColorComboBoxTest { public static void main(String[] args) { try { if (args.length == 0) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } Box box = new Box(BoxLayout.PAGE_AXIS); JPanel panel = new JPanel(); panel.add(new JColorComboBox(JColorComboBox.LINE, true)); panel.add(new JColorComboBox(JColorComboBox.RECT, new Color[] { Color.red, Color.green, Color.blue, Color.orange })); panel.add(new JColorComboBox(JColorComboBox.TEXT_ONLY)); box.add(panel); panel = new JPanel(); panel.add(new JColorComboBox(JColorComboBox.LINE)); panel.add(new JColorComboBox(JColorComboBox.RECT, true)); panel.add(new JColorComboBox(JColorComboBox.LINE, new Color[] { Color.red, Color.green, Color.blue, Color.orange }, new String[] { "Mike's car", "Joe's pants", "Albert's pen", "Fred's cup" })); box.add(panel); panel = new JPanel(); JColorComboBox combo = new JColorComboBox(JColorComboBox.RECT, false); combo.setType(JColorComboBox.LINE); combo.setColorThickness(3); combo.setShowText(true); combo.setColorWidth(200); combo.setFont(new Font("Serif", Font.ITALIC, 16)); combo.setBackground(new Color(230, 240, 250)); panel.add(combo); box.add(panel); JFrame f = new JFrame("JColorComboBox test"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setContentPane(box); f.pack(); f.setLocationByPlatform(true); f.setVisible(true); } catch (Exception e) { } } }