1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
729 JScrollBar sb = (JScrollBar)pce.getOldValue();
730 if (sb != null) {
731 if (cl != null) {
732 sb.getModel().removeChangeListener(cl);
733 }
734 if (pcl != null) {
735 sb.removePropertyChangeListener(pcl);
736 }
737 }
738 sb = (JScrollBar)pce.getNewValue();
739 if (sb != null) {
740 if (cl != null) {
741 sb.getModel().addChangeListener(cl);
742 }
743 if (pcl != null) {
744 sb.addPropertyChangeListener(pcl);
745 }
746 }
747 }
748
749 public class PropertyChangeHandler implements PropertyChangeListener
750 {
751
752 // NOTE: This class exists only for backward compatibility. All
753 // its functionality has been moved into Handler. If you need to add
754 // new functionality add it to the Handler, but make sure this
755 // class calls into the Handler.
756
757 public void propertyChange(PropertyChangeEvent e)
758 {
759 getHandler().propertyChange(e);
760 }
761 }
762
763
764
765 /**
766 * Creates an instance of {@code PropertyChangeListener} that's added to
767 * the {@code JScrollPane} by {@code installUI()}. Subclasses can override
768 * this method to return a custom {@code PropertyChangeListener}, e.g.
769 * <pre>
770 * class MyScrollPaneUI extends BasicScrollPaneUI {
771 * protected PropertyChangeListener <b>createPropertyChangeListener</b>() {
772 * return new MyPropertyChangeListener();
773 * }
774 * public class MyPropertyChangeListener extends PropertyChangeListener {
775 * public void propertyChange(PropertyChangeEvent e) {
776 * if (e.getPropertyName().equals("viewport")) {
|
1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
729 JScrollBar sb = (JScrollBar)pce.getOldValue();
730 if (sb != null) {
731 if (cl != null) {
732 sb.getModel().removeChangeListener(cl);
733 }
734 if (pcl != null) {
735 sb.removePropertyChangeListener(pcl);
736 }
737 }
738 sb = (JScrollBar)pce.getNewValue();
739 if (sb != null) {
740 if (cl != null) {
741 sb.getModel().addChangeListener(cl);
742 }
743 if (pcl != null) {
744 sb.addPropertyChangeListener(pcl);
745 }
746 }
747 }
748
749 /**
750 * Property change handler.
751 */
752 public class PropertyChangeHandler implements PropertyChangeListener
753 {
754
755 // NOTE: This class exists only for backward compatibility. All
756 // its functionality has been moved into Handler. If you need to add
757 // new functionality add it to the Handler, but make sure this
758 // class calls into the Handler.
759
760 /**
761 * {@inheritDoc}
762 */
763 public void propertyChange(PropertyChangeEvent e)
764 {
765 getHandler().propertyChange(e);
766 }
767 }
768
769
770
771 /**
772 * Creates an instance of {@code PropertyChangeListener} that's added to
773 * the {@code JScrollPane} by {@code installUI()}. Subclasses can override
774 * this method to return a custom {@code PropertyChangeListener}, e.g.
775 * <pre>
776 * class MyScrollPaneUI extends BasicScrollPaneUI {
777 * protected PropertyChangeListener <b>createPropertyChangeListener</b>() {
778 * return new MyPropertyChangeListener();
779 * }
780 * public class MyPropertyChangeListener extends PropertyChangeListener {
781 * public void propertyChange(PropertyChangeEvent e) {
782 * if (e.getPropertyName().equals("viewport")) {
|