2376N/A/*
2685N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2376N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2376N/A *
2376N/A * This code is free software; you can redistribute it and/or modify it
2376N/A * under the terms of the GNU General Public License version 2 only, as
2376N/A * published by the Free Software Foundation.
2376N/A *
2376N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2376N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2376N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2376N/A * version 2 for more details (a copy is included in the LICENSE file that
2376N/A * accompanied this code).
2376N/A *
2376N/A * You should have received a copy of the GNU General Public License version
2376N/A * 2 along with this work; if not, write to the Free Software Foundation,
2376N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2376N/A *
2685N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2685N/A * or visit www.oracle.com if you need additional information or have any
2685N/A * questions.
2376N/A */
2376N/A
2376N/A/* @test
2376N/A * @bug 6953396
2376N/A * @summary javax.swing.plaf.basic.BasicViewportUI.uninstallDefaults() is not called when UI is uninstalled
2376N/A * @author Alexander Potochkin
2376N/A */
2376N/A
2376N/Aimport javax.swing.*;
2376N/Aimport javax.swing.plaf.basic.BasicViewportUI;
2376N/A
2376N/Apublic class bug6953396 {
2376N/A static volatile boolean flag;
2376N/A
2376N/A public static void main(String[] args) throws Exception {
2376N/A SwingUtilities.invokeAndWait(new Runnable() {
2376N/A @Override
2376N/A public void run() {
2376N/A BasicViewportUI ui = new BasicViewportUI() {
2376N/A
2376N/A @Override
2376N/A protected void installDefaults(JComponent c) {
2376N/A super.installDefaults(c);
2376N/A flag = true;
2376N/A }
2376N/A
2376N/A @Override
2376N/A protected void uninstallDefaults(JComponent c) {
2376N/A super.uninstallDefaults(c);
2376N/A flag = false;
2376N/A }
2376N/A };
2376N/A
2376N/A JViewport viewport = new JViewport();
2376N/A viewport.setUI(ui);
2376N/A viewport.setUI(null);
2376N/A }
2376N/A });
2376N/A if (flag) {
2376N/A throw new RuntimeException("uninstallDefaults() hasn't been called");
2376N/A }
2376N/A }
2376N/A}