242N/A/*
2362N/A * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
242N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
242N/A *
242N/A * This code is free software; you can redistribute it and/or modify it
242N/A * under the terms of the GNU General Public License version 2 only, as
242N/A * published by the Free Software Foundation.
242N/A *
242N/A * This code is distributed in the hope that it will be useful, but WITHOUT
242N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
242N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
242N/A * version 2 for more details (a copy is included in the LICENSE file that
242N/A * accompanied this code).
242N/A *
242N/A * You should have received a copy of the GNU General Public License version
242N/A * 2 along with this work; if not, write to the Free Software Foundation,
242N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
242N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
242N/A */
242N/A
242N/A/*
242N/A * @test
242N/A * @bug 6348456
242N/A * @summary Tests model changing
242N/A * @author Sergey Malenkov
242N/A * @run applet/manual=yesno Test6348456.html
242N/A */
242N/A
242N/Aimport java.awt.BorderLayout;
242N/Aimport java.awt.Color;
242N/Aimport java.awt.event.ActionEvent;
242N/Aimport java.awt.event.ActionListener;
242N/Aimport javax.swing.JApplet;
242N/Aimport javax.swing.JButton;
242N/Aimport javax.swing.JColorChooser;
242N/Aimport javax.swing.colorchooser.DefaultColorSelectionModel;
242N/A
242N/Apublic final class Test6348456 extends JApplet implements ActionListener {
242N/A
242N/A private static final DefaultColorSelectionModel WHITE = new DefaultColorSelectionModel(Color.WHITE);
242N/A private static final DefaultColorSelectionModel BLACK = new DefaultColorSelectionModel(Color.BLACK);
242N/A
242N/A private JColorChooser chooser;
242N/A
242N/A @Override
242N/A public void init() {
242N/A JButton button = new JButton("Swap models");
242N/A button.addActionListener(this);
242N/A
242N/A this.chooser = new JColorChooser(Color.RED);
242N/A this.chooser.setSelectionModel(WHITE);
242N/A
242N/A add(BorderLayout.NORTH, button);
242N/A add(BorderLayout.CENTER, this.chooser);
242N/A }
242N/A
242N/A public void actionPerformed(ActionEvent event){
242N/A this.chooser.setSelectionModel(this.chooser.getSelectionModel() == BLACK ? WHITE : BLACK);
242N/A }
242N/A}