src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2013, 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


1877         }
1878 
1879         public void focusLost(FocusEvent e) {
1880             getHandler().focusLost(e);
1881         }
1882     }
1883 
1884     /**
1885      * As of Java 2 platform v1.3 this undocumented class is no longer used.
1886      * The recommended approach to creating bindings is to use a
1887      * combination of an <code>ActionMap</code>, to contain the action,
1888      * and an <code>InputMap</code> to contain the mapping from KeyStroke
1889      * to action description. The InputMap is is usually described in the
1890      * LookAndFeel tables.
1891      * <p>
1892      * Please refer to the key bindings specification for further details.
1893      * <p>
1894      * This class should be treated as a &quot;protected&quot; inner class.
1895      * Instantiate it only within subclasses of <code>Foo</code>.
1896      */

1897     public class ActionScroller extends AbstractAction {
1898         // NOTE: This class exists only for backward compatibility. All
1899         // its functionality has been moved into Actions. If you need to add
1900         // new functionality add it to the Actions, but make sure this
1901         // class calls into the Actions.
1902         int dir;
1903         boolean block;
1904         JSlider slider;
1905 
1906         public ActionScroller( JSlider slider, int dir, boolean block) {
1907             this.dir = dir;
1908             this.block = block;
1909             this.slider = slider;
1910         }
1911 
1912         public void actionPerformed(ActionEvent e) {
1913             SHARED_ACTION.scroll(slider, BasicSliderUI.this, dir, block);
1914         }
1915 
1916         public boolean isEnabled() {
1917             boolean b = true;
1918             if (slider != null) {
1919                 b = slider.isEnabled();
1920             }
1921             return b;
1922         }
1923 
1924     }
1925 
1926 
1927     /**
1928      * A static version of the above.
1929      */

1930     static class SharedActionScroller extends AbstractAction {
1931         // NOTE: This class exists only for backward compatibility. All
1932         // its functionality has been moved into Actions. If you need to add
1933         // new functionality add it to the Actions, but make sure this
1934         // class calls into the Actions.
1935         int dir;
1936         boolean block;
1937 
1938         public SharedActionScroller(int dir, boolean block) {
1939             this.dir = dir;
1940             this.block = block;
1941         }
1942 
1943         public void actionPerformed(ActionEvent evt) {
1944             JSlider slider = (JSlider)evt.getSource();
1945             BasicSliderUI ui = (BasicSliderUI)BasicLookAndFeel.getUIOfType(
1946                     slider.getUI(), BasicSliderUI.class);
1947             if (ui == null) {
1948                 return;
1949             }


   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


1877         }
1878 
1879         public void focusLost(FocusEvent e) {
1880             getHandler().focusLost(e);
1881         }
1882     }
1883 
1884     /**
1885      * As of Java 2 platform v1.3 this undocumented class is no longer used.
1886      * The recommended approach to creating bindings is to use a
1887      * combination of an <code>ActionMap</code>, to contain the action,
1888      * and an <code>InputMap</code> to contain the mapping from KeyStroke
1889      * to action description. The InputMap is is usually described in the
1890      * LookAndFeel tables.
1891      * <p>
1892      * Please refer to the key bindings specification for further details.
1893      * <p>
1894      * This class should be treated as a &quot;protected&quot; inner class.
1895      * Instantiate it only within subclasses of <code>Foo</code>.
1896      */
1897     @SuppressWarnings("serial") // Superclass is not serializable across versions
1898     public class ActionScroller extends AbstractAction {
1899         // NOTE: This class exists only for backward compatibility. All
1900         // its functionality has been moved into Actions. If you need to add
1901         // new functionality add it to the Actions, but make sure this
1902         // class calls into the Actions.
1903         int dir;
1904         boolean block;
1905         JSlider slider;
1906 
1907         public ActionScroller( JSlider slider, int dir, boolean block) {
1908             this.dir = dir;
1909             this.block = block;
1910             this.slider = slider;
1911         }
1912 
1913         public void actionPerformed(ActionEvent e) {
1914             SHARED_ACTION.scroll(slider, BasicSliderUI.this, dir, block);
1915         }
1916 
1917         public boolean isEnabled() {
1918             boolean b = true;
1919             if (slider != null) {
1920                 b = slider.isEnabled();
1921             }
1922             return b;
1923         }
1924 
1925     }
1926 
1927 
1928     /**
1929      * A static version of the above.
1930      */
1931     @SuppressWarnings("serial") // Superclass is not serializable across versions
1932     static class SharedActionScroller extends AbstractAction {
1933         // NOTE: This class exists only for backward compatibility. All
1934         // its functionality has been moved into Actions. If you need to add
1935         // new functionality add it to the Actions, but make sure this
1936         // class calls into the Actions.
1937         int dir;
1938         boolean block;
1939 
1940         public SharedActionScroller(int dir, boolean block) {
1941             this.dir = dir;
1942             this.block = block;
1943         }
1944 
1945         public void actionPerformed(ActionEvent evt) {
1946             JSlider slider = (JSlider)evt.getSource();
1947             BasicSliderUI ui = (BasicSliderUI)BasicLookAndFeel.getUIOfType(
1948                     slider.getUI(), BasicSliderUI.class);
1949             if (ui == null) {
1950                 return;
1951             }