< prev index next >

src/java.desktop/share/classes/java/awt/Scrollbar.java

Print this page
rev 56131 : 8225372: accessibility errors in tables in java.desktop files
Reviewed-by: aivanov
   1 /*
   2  * Copyright (c) 1995, 2017, 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


  24  */
  25 package java.awt;
  26 
  27 import java.awt.peer.ScrollbarPeer;
  28 import java.awt.event.*;
  29 import java.util.EventListener;
  30 import java.io.ObjectOutputStream;
  31 import java.io.ObjectInputStream;
  32 import java.io.IOException;
  33 import javax.accessibility.*;
  34 
  35 
  36 /**
  37  * The {@code Scrollbar} class embodies a scroll bar, a
  38  * familiar user-interface object. A scroll bar provides a
  39  * convenient means for allowing a user to select from a
  40  * range of values. The following three vertical
  41  * scroll bars could be used as slider controls to pick
  42  * the red, green, and blue components of a color:
  43  * <p>
  44  * <img src="doc-files/Scrollbar-1.gif" alt="Image shows 3 vertical sliders, side-by-side."
  45  * style="float:center; margin: 7px 10px;">
  46  * <p>
  47  * Each scroll bar in this example could be created with
  48  * code similar to the following:
  49  *
  50  * <hr><blockquote><pre>
  51  * redSlider=new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 255);
  52  * add(redSlider);
  53  * </pre></blockquote><hr>
  54  * <p>
  55  * Alternatively, a scroll bar can represent a range of values. For
  56  * example, if a scroll bar is used for scrolling through text, the
  57  * width of the "bubble" (also called the "thumb" or "scroll box")
  58  * can be used to represent the amount of text that is visible.
  59  * Here is an example of a scroll bar that represents a range:
  60  * <p>
  61  * <img src="doc-files/Scrollbar-2.gif"
  62  * alt="Image shows horizontal slider with starting range of 0 and ending range of 300. The slider thumb is labeled 60."
  63  * style="float:center; margin: 7px 10px;">
  64  * <p>
  65  * The value range represented by the bubble in this example
  66  * is the <em>visible amount</em>. The horizontal scroll bar
  67  * in this example could be created with code like the following:
  68  *
  69  * <hr><blockquote><pre>
  70  * ranger = new Scrollbar(Scrollbar.HORIZONTAL, 0, 60, 0, 300);
  71  * add(ranger);
  72  * </pre></blockquote><hr>
  73  * <p>
  74  * Note that the actual maximum value of the scroll bar is the
  75  * {@code maximum} minus the {@code visible amount}.
  76  * In the previous example, because the {@code maximum} is
  77  * 300 and the {@code visible amount} is 60, the actual maximum
  78  * value is 240.  The range of the scrollbar track is 0 - 300.
  79  * The left side of the bubble indicates the value of the
  80  * scroll bar.
  81  * <p>
  82  * Normally, the user changes the value of the scroll bar by
  83  * making a gesture with the mouse. For example, the user can


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


  24  */
  25 package java.awt;
  26 
  27 import java.awt.peer.ScrollbarPeer;
  28 import java.awt.event.*;
  29 import java.util.EventListener;
  30 import java.io.ObjectOutputStream;
  31 import java.io.ObjectInputStream;
  32 import java.io.IOException;
  33 import javax.accessibility.*;
  34 
  35 
  36 /**
  37  * The {@code Scrollbar} class embodies a scroll bar, a
  38  * familiar user-interface object. A scroll bar provides a
  39  * convenient means for allowing a user to select from a
  40  * range of values. The following three vertical
  41  * scroll bars could be used as slider controls to pick
  42  * the red, green, and blue components of a color:
  43  * <p>
  44  * <img src="doc-files/Scrollbar-1.gif" alt="Image shows 3 vertical sliders,
  45  * side-by-side." style="margin: 7px 10px;">
  46  * <p>
  47  * Each scroll bar in this example could be created with
  48  * code similar to the following:
  49  *
  50  * <hr><blockquote><pre>
  51  * redSlider=new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 255);
  52  * add(redSlider);
  53  * </pre></blockquote><hr>
  54  * <p>
  55  * Alternatively, a scroll bar can represent a range of values. For
  56  * example, if a scroll bar is used for scrolling through text, the
  57  * width of the "bubble" (also called the "thumb" or "scroll box")
  58  * can be used to represent the amount of text that is visible.
  59  * Here is an example of a scroll bar that represents a range:
  60  * <p>
  61  * <img src="doc-files/Scrollbar-2.gif"
  62  * alt="Image shows horizontal slider with starting range of 0 and ending range
  63  * of 300. The slider thumb is labeled 60." style="margin: 7px 10px;">
  64  * <p>
  65  * The value range represented by the bubble in this example
  66  * is the <em>visible amount</em>. The horizontal scroll bar
  67  * in this example could be created with code like the following:
  68  *
  69  * <hr><blockquote><pre>
  70  * ranger = new Scrollbar(Scrollbar.HORIZONTAL, 0, 60, 0, 300);
  71  * add(ranger);
  72  * </pre></blockquote><hr>
  73  * <p>
  74  * Note that the actual maximum value of the scroll bar is the
  75  * {@code maximum} minus the {@code visible amount}.
  76  * In the previous example, because the {@code maximum} is
  77  * 300 and the {@code visible amount} is 60, the actual maximum
  78  * value is 240.  The range of the scrollbar track is 0 - 300.
  79  * The left side of the bubble indicates the value of the
  80  * scroll bar.
  81  * <p>
  82  * Normally, the user changes the value of the scroll bar by
  83  * making a gesture with the mouse. For example, the user can


< prev index next >