src/java.desktop/share/classes/java/awt/Scrollbar.java
author serb
Mon, 09 Sep 2019 12:23:22 -0700
changeset 58325 d32a3b1ca84a
parent 47498 aa0344e6f39b
permissions -rw-r--r--
8225372: accessibility errors in tables in java.desktop files Reviewed-by: aivanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58325
d32a3b1ca84a 8225372: accessibility errors in tables in java.desktop files
serb
parents: 47498
diff changeset
     2
 * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.peer.ScrollbarPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.EventListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    37
 * The {@code Scrollbar} class embodies a scroll bar, a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * familiar user-interface object. A scroll bar provides a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * convenient means for allowing a user to select from a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * range of values. The following three vertical
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * scroll bars could be used as slider controls to pick
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * the red, green, and blue components of a color:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <p>
58325
d32a3b1ca84a 8225372: accessibility errors in tables in java.desktop files
serb
parents: 47498
diff changeset
    44
 * <img src="doc-files/Scrollbar-1.gif" alt="Image shows 3 vertical sliders,
d32a3b1ca84a 8225372: accessibility errors in tables in java.desktop files
serb
parents: 47498
diff changeset
    45
 * side-by-side." style="margin: 7px 10px;">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Each scroll bar in this example could be created with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * code similar to the following:
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 20451
diff changeset
    49
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <hr><blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * redSlider=new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 255);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * add(redSlider);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * </pre></blockquote><hr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * Alternatively, a scroll bar can represent a range of values. For
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * example, if a scroll bar is used for scrolling through text, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * width of the "bubble" (also called the "thumb" or "scroll box")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * can be used to represent the amount of text that is visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * Here is an example of a scroll bar that represents a range:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <img src="doc-files/Scrollbar-2.gif"
58325
d32a3b1ca84a 8225372: accessibility errors in tables in java.desktop files
serb
parents: 47498
diff changeset
    62
 * alt="Image shows horizontal slider with starting range of 0 and ending range
d32a3b1ca84a 8225372: accessibility errors in tables in java.desktop files
serb
parents: 47498
diff changeset
    63
 * of 300. The slider thumb is labeled 60." style="margin: 7px 10px;">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * The value range represented by the bubble in this example
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * is the <em>visible amount</em>. The horizontal scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * in this example could be created with code like the following:
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 20451
diff changeset
    68
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <hr><blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * ranger = new Scrollbar(Scrollbar.HORIZONTAL, 0, 60, 0, 300);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * add(ranger);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * </pre></blockquote><hr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * Note that the actual maximum value of the scroll bar is the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    75
 * {@code maximum} minus the {@code visible amount}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    76
 * In the previous example, because the {@code maximum} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    77
 * 300 and the {@code visible amount} is 60, the actual maximum
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * value is 240.  The range of the scrollbar track is 0 - 300.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * The left side of the bubble indicates the value of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * Normally, the user changes the value of the scroll bar by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * making a gesture with the mouse. For example, the user can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * drag the scroll bar's bubble up and down, or click in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * scroll bar's unit increment or block increment areas. Keyboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * gestures can also be mapped to the scroll bar. By convention,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * the <b>Page&nbsp;Up</b> and <b>Page&nbsp;Down</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * keys are equivalent to clicking in the scroll bar's block
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * increment and block decrement areas.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * When the user changes the value of the scroll bar, the scroll bar
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    92
 * receives an instance of {@code AdjustmentEvent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * The scroll bar processes this event, passing it along to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * any registered listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * Any object that wishes to be notified of changes to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * scroll bar's value should implement
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    98
 * {@code AdjustmentListener}, an interface defined in
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    99
 * the package {@code java.awt.event}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * Listeners can be added and removed dynamically by calling
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   101
 * the methods {@code addAdjustmentListener} and
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   102
 * {@code removeAdjustmentListener}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   104
 * The {@code AdjustmentEvent} class defines five types
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * of adjustment event, listed here:
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 20451
diff changeset
   106
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * <ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   108
 * <li>{@code AdjustmentEvent.TRACK} is sent out when the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * user drags the scroll bar's bubble.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   110
 * <li>{@code AdjustmentEvent.UNIT_INCREMENT} is sent out
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * when the user clicks in the left arrow of a horizontal scroll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * bar, or the top arrow of a vertical scroll bar, or makes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * equivalent gesture from the keyboard.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   114
 * <li>{@code AdjustmentEvent.UNIT_DECREMENT} is sent out
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * when the user clicks in the right arrow of a horizontal scroll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * bar, or the bottom arrow of a vertical scroll bar, or makes the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * equivalent gesture from the keyboard.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   118
 * <li>{@code AdjustmentEvent.BLOCK_INCREMENT} is sent out
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * when the user clicks in the track, to the left of the bubble
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * on a horizontal scroll bar, or above the bubble on a vertical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * scroll bar. By convention, the <b>Page&nbsp;Up</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * key is equivalent, if the user is using a keyboard that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * defines a <b>Page&nbsp;Up</b> key.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   124
 * <li>{@code AdjustmentEvent.BLOCK_DECREMENT} is sent out
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * when the user clicks in the track, to the right of the bubble
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * on a horizontal scroll bar, or below the bubble on a vertical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * scroll bar. By convention, the <b>Page&nbsp;Down</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * key is equivalent, if the user is using a keyboard that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * defines a <b>Page&nbsp;Down</b> key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * The JDK&nbsp;1.0 event system is supported for backwards
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * compatibility, but its use with newer versions of the platform is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * discouraged. The five types of adjustment events introduced
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * with JDK&nbsp;1.1 correspond to the five event types
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * that are associated with scroll bars in previous platform versions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * The following list gives the adjustment event type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * and the corresponding JDK&nbsp;1.0 event type it replaces.
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 20451
diff changeset
   139
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * <ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   141
 * <li>{@code AdjustmentEvent.TRACK} replaces
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   142
 * {@code Event.SCROLL_ABSOLUTE}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   143
 * <li>{@code AdjustmentEvent.UNIT_INCREMENT} replaces
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   144
 * {@code Event.SCROLL_LINE_UP}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   145
 * <li>{@code AdjustmentEvent.UNIT_DECREMENT} replaces
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   146
 * {@code Event.SCROLL_LINE_DOWN}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   147
 * <li>{@code AdjustmentEvent.BLOCK_INCREMENT} replaces
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   148
 * {@code Event.SCROLL_PAGE_UP}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   149
 * <li>{@code AdjustmentEvent.BLOCK_DECREMENT} replaces
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   150
 * {@code Event.SCROLL_PAGE_DOWN}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   153
 * <b>Note</b>: We recommend using a {@code Scrollbar}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * for value selection only.  If you want to implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * a scrollable component inside a container, we recommend you use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * a {@link ScrollPane ScrollPane}. If you use a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   157
 * {@code Scrollbar} for this purpose, you are likely to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * encounter issues with painting, key handling, sizing and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 * positioning.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 * @author      Sami Shaio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * @see         java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 * @see         java.awt.event.AdjustmentListener
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   164
 * @since       1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
public class Scrollbar extends Component implements Adjustable, Accessible {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * A constant that indicates a horizontal scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public static final int     HORIZONTAL = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * A constant that indicates a vertical scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public static final int     VERTICAL   = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   179
     * The value of the {@code Scrollbar}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   180
     * This property must be greater than or equal to {@code minimum}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * and less than or equal to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   182
     * {@code maximum - visibleAmount}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @see #getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @see #setValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    int value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   191
     * The maximum value of the {@code Scrollbar}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   192
     * This value must be greater than the {@code minimum}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * value.<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @see #getMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @see #setMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    int maximum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   202
     * The minimum value of the {@code Scrollbar}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   203
     * This value must be less than the {@code maximum}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * value.<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @see #getMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @see #setMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    int minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   213
     * The size of the {@code Scrollbar}'s bubble.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * When a scroll bar is used to select a range of values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * the visibleAmount represents the size of this range.
7000
5ddef688a02d 6659228: GridBagConstraints API typo - 'ComponentOrienation' (missing t)
dav
parents: 5506
diff changeset
   216
     * Depending on platform, this may be visually indicated
5ddef688a02d 6659228: GridBagConstraints API typo - 'ComponentOrienation' (missing t)
dav
parents: 5506
diff changeset
   217
     * by the size of the bubble.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @see #getVisibleAmount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * @see #setVisibleAmount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    int visibleAmount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   226
     * The {@code Scrollbar}'s orientation--being either horizontal
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * or vertical.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * This value should be specified when the scrollbar is created.<BR>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   229
     * orientation can be either : {@code VERTICAL} or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   230
     * {@code HORIZONTAL} only.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @see #getOrientation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @see #setOrientation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    int orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * The amount by which the scrollbar value will change when going
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * up or down by a line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * This value must be greater than zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @see #getLineIncrement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * @see #setLineIncrement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    int lineIncrement = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * The amount by which the scrollbar value will change when going
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * up or down by a page.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * This value must be greater than zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @see #getPageIncrement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @see #setPageIncrement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    int pageIncrement = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   261
     * The adjusting status of the {@code Scrollbar}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * True if the value is in the process of changing as a result of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * actions being taken by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * @see #getValueIsAdjusting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @see #setValueIsAdjusting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    transient boolean isAdjusting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    transient AdjustmentListener adjustmentListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    private static final String base = "scrollbar";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    private static int nameCounter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    private static final long serialVersionUID = 8451667562882310543L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Initialize JNI field and method IDs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        Toolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * Constructs a new vertical scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * The default properties of the scroll bar are listed in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * the following table:
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 20451
diff changeset
   298
     *
45648
87c997b74bb8 8180326: Update the tables in java.desktop to be HTML-5 friendly
serb
parents: 35667
diff changeset
   299
     * <table class="striped">
87c997b74bb8 8180326: Update the tables in java.desktop to be HTML-5 friendly
serb
parents: 35667
diff changeset
   300
     * <caption>Scrollbar default properties</caption>
87c997b74bb8 8180326: Update the tables in java.desktop to be HTML-5 friendly
serb
parents: 35667
diff changeset
   301
     * <thead>
47498
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   302
     *   <tr>
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   303
     *     <th scope="col">Property
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   304
     *     <th scope="col">Description
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   305
     *     <th scope="col">Default Value
45648
87c997b74bb8 8180326: Update the tables in java.desktop to be HTML-5 friendly
serb
parents: 35667
diff changeset
   306
     * </thead>
87c997b74bb8 8180326: Update the tables in java.desktop to be HTML-5 friendly
serb
parents: 35667
diff changeset
   307
     * <tbody>
47498
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   308
     *   <tr>
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   309
     *     <th scope="row">orientation
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   310
     *     <td>indicates whether the scroll bar is vertical or horizontal
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   311
     *     <td>{@code Scrollbar.VERTICAL}
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   312
     *   <tr>
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   313
     *     <th scope="row">value
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   314
     *     <td>value which controls the location of the scroll bar's bubble
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   315
     *     <td>0
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   316
     *   <tr>
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   317
     *     <th scope="row">visible amount
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   318
     *     <td>visible amount of the scroll bar's range, typically represented
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   319
     *     by the size of the scroll bar's bubble
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   320
     *     <td>10
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   321
     *   <tr>
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   322
     *     <th scope="row">minimum
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   323
     *     <td>minimum value of the scroll bar
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   324
     *     <td>0
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   325
     *   <tr>
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   326
     *     <th scope="row">maximum
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   327
     *     <td>maximum value of the scroll bar
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   328
     *     <td>100
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   329
     *   <tr>
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   330
     *     <th scope="row">unit increment
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   331
     *     <td>amount the value changes when the Line Up or Line Down key is
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   332
     *     pressed, or when the end arrows of the scrollbar are clicked
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   333
     *     <td>1
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   334
     *   <tr>
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   335
     *     <th scope="row">block increment
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   336
     *     <td>amount the value changes when the Page Up or Page Down key is
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   337
     *     pressed, or when the scrollbar track is clicked<br>on either side of
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   338
     *     the bubble
aa0344e6f39b 8184219: Fix accessibility of tables in the java.desktop module
serb
parents: 47216
diff changeset
   339
     *     <td>10
45648
87c997b74bb8 8180326: Update the tables in java.desktop to be HTML-5 friendly
serb
parents: 35667
diff changeset
   340
     * </tbody>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    public Scrollbar() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        this(VERTICAL, 0, 10, 0, 100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * Constructs a new scroll bar with the specified orientation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   354
     * The {@code orientation} argument must take one of the two
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   355
     * values {@code Scrollbar.HORIZONTAL},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   356
     * or {@code Scrollbar.VERTICAL},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * indicating a horizontal or vertical scroll bar, respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @param       orientation   indicates the orientation of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * @exception   IllegalArgumentException    when an illegal value for
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   361
     *                    the {@code orientation} argument is supplied
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    public Scrollbar(int orientation) throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        this(orientation, 0, 10, 0, 100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * Constructs a new scroll bar with the specified orientation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * initial value, visible amount, and minimum and maximum values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   374
     * The {@code orientation} argument must take one of the two
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   375
     * values {@code Scrollbar.HORIZONTAL},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   376
     * or {@code Scrollbar.VERTICAL},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * indicating a horizontal or vertical scroll bar, respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * The parameters supplied to this constructor are subject to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * constraints described in {@link #setValues(int, int, int, int)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * @param     orientation   indicates the orientation of the scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * @param     value     the initial value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @param     visible   the visible amount of the scroll bar, typically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     *                      represented by the size of the bubble
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @param     minimum   the minimum value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @param     maximum   the maximum value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * @exception IllegalArgumentException    when an illegal value for
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   389
     *                    the {@code orientation} argument is supplied
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * @see #setValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    public Scrollbar(int orientation, int value, int visible, int minimum,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        int maximum) throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        GraphicsEnvironment.checkHeadless();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        switch (orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
          case HORIZONTAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
          case VERTICAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            this.orientation = orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            throw new IllegalArgumentException("illegal scrollbar orientation");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        setValues(value, visible, minimum, maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   410
     * Constructs a name for this component.  Called by {@code getName}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   411
     * when the name is {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    String constructComponentName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        synchronized (Scrollbar.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            return base + nameCounter++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   420
     * Creates the {@code Scrollbar}'s peer.  The peer allows you to modify
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   421
     * the appearance of the {@code Scrollbar} without changing any of its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            if (peer == null)
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
   427
                peer = getComponentFactory().createScrollbar(this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            super.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * Returns the orientation of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * @return    the orientation of this scroll bar, either
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   436
     *               {@code Scrollbar.HORIZONTAL} or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   437
     *               {@code Scrollbar.VERTICAL}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @see       java.awt.Scrollbar#setOrientation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    public int getOrientation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        return orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * Sets the orientation for this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @param orientation  the orientation of this scroll bar, either
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   448
     *               {@code Scrollbar.HORIZONTAL} or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   449
     *               {@code Scrollbar.VERTICAL}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * @see       java.awt.Scrollbar#getOrientation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @exception   IllegalArgumentException  if the value supplied
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   452
     *                   for {@code orientation} is not a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     *                   legal value
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   454
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    public void setOrientation(int orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            if (orientation == this.orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            switch (orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                case HORIZONTAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                case VERTICAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                    this.orientation = orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                    throw new IllegalArgumentException("illegal scrollbar orientation");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            /* Create a new peer with the specified orientation. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                removeNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        if (accessibleContext != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            accessibleContext.firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                    AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                    ((orientation == VERTICAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                     ? AccessibleState.HORIZONTAL : AccessibleState.VERTICAL),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                    ((orientation == VERTICAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                     ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * Gets the current value of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * @return      the current value of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * @see         java.awt.Scrollbar#getMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * @see         java.awt.Scrollbar#getMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    public int getValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * Sets the value of this scroll bar to the specified value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   500
     * If the value supplied is less than the current {@code minimum}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   501
     * or greater than the current {@code maximum - visibleAmount},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   502
     * then either {@code minimum} or {@code maximum - visibleAmount}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * is substituted, as appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * Normally, a program should change a scroll bar's
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   506
     * value only by calling {@code setValues}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   507
     * The {@code setValues} method simultaneously
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * and synchronously sets the minimum, maximum, visible amount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * and value properties of a scroll bar, so that they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * mutually consistent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * Calling this method does not fire an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   513
     * {@code AdjustmentEvent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * @param       newValue   the new value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * @see         java.awt.Scrollbar#setValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @see         java.awt.Scrollbar#getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @see         java.awt.Scrollbar#getMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * @see         java.awt.Scrollbar#getMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    public void setValue(int newValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        // Use setValues so that a consistent policy relating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        // minimum, maximum, visible amount, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        setValues(newValue, visibleAmount, minimum, maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * Gets the minimum value of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * @return      the minimum value of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * @see         java.awt.Scrollbar#getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * @see         java.awt.Scrollbar#getMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    public int getMinimum() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        return minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * Sets the minimum value of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   541
     * When {@code setMinimum} is called, the minimum value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * is changed, and other values (including the maximum, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * visible amount, and the current scroll bar value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * are changed to be consistent with the new minimum.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * Normally, a program should change a scroll bar's minimum
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   547
     * value only by calling {@code setValues}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   548
     * The {@code setValues} method simultaneously
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * and synchronously sets the minimum, maximum, visible amount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * and value properties of a scroll bar, so that they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * mutually consistent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   553
     * Note that setting the minimum value to {@code Integer.MAX_VALUE}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * will result in the new minimum value being set to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   555
     * {@code Integer.MAX_VALUE - 1}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @param       newMinimum   the new minimum value for this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * @see         java.awt.Scrollbar#setValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * @see         java.awt.Scrollbar#setMaximum
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   560
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    public void setMinimum(int newMinimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        // No checks are necessary in this method since minimum is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        // the first variable checked in the setValues function.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        // Use setValues so that a consistent policy relating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        // minimum, maximum, visible amount, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        setValues(value, visibleAmount, newMinimum, maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * Gets the maximum value of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * @return      the maximum value of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * @see         java.awt.Scrollbar#getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @see         java.awt.Scrollbar#getMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    public int getMaximum() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        return maximum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * Sets the maximum value of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   585
     * When {@code setMaximum} is called, the maximum value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * is changed, and other values (including the minimum, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * visible amount, and the current scroll bar value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * are changed to be consistent with the new maximum.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * Normally, a program should change a scroll bar's maximum
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   591
     * value only by calling {@code setValues}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   592
     * The {@code setValues} method simultaneously
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * and synchronously sets the minimum, maximum, visible amount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * and value properties of a scroll bar, so that they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * mutually consistent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   597
     * Note that setting the maximum value to {@code Integer.MIN_VALUE}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * will result in the new maximum value being set to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   599
     * {@code Integer.MIN_VALUE + 1}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * @param       newMaximum   the new maximum value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     *                     for this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * @see         java.awt.Scrollbar#setValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * @see         java.awt.Scrollbar#setMinimum
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   605
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    public void setMaximum(int newMaximum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        // minimum is checked first in setValues, so we need to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        // enforce minimum and maximum checks here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        if (newMaximum == Integer.MIN_VALUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            newMaximum = Integer.MIN_VALUE + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        if (minimum >= newMaximum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            minimum = newMaximum - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        // Use setValues so that a consistent policy relating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        // minimum, maximum, visible amount, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        setValues(value, visibleAmount, minimum, newMaximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * Gets the visible amount of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * When a scroll bar is used to select a range of values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * the visible amount is used to represent the range of values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * that are currently visible.  The size of the scroll bar's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * bubble (also called a thumb or scroll box), usually gives a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * visual representation of the relationship of the visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * amount to the range of the scroll bar.
7000
5ddef688a02d 6659228: GridBagConstraints API typo - 'ComponentOrienation' (missing t)
dav
parents: 5506
diff changeset
   632
     * Note that depending on platform, the value of the visible amount property
5ddef688a02d 6659228: GridBagConstraints API typo - 'ComponentOrienation' (missing t)
dav
parents: 5506
diff changeset
   633
     * may not be visually indicated by the size of the bubble.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * The scroll bar's bubble may not be displayed when it is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * moveable (e.g. when it takes up the entire length of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * scroll bar's track, or when the scroll bar is disabled).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * Whether the bubble is displayed or not will not affect
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   639
     * the value returned by {@code getVisibleAmount}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * @return      the visible amount of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * @see         java.awt.Scrollbar#setVisibleAmount
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   643
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    public int getVisibleAmount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        return getVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   650
     * Returns the visible amount of this scroll bar.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   651
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   652
     * @return the visible amount of this scroll bar
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   654
     * replaced by {@code getVisibleAmount()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    public int getVisible() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        return visibleAmount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * Sets the visible amount of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * When a scroll bar is used to select a range of values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * the visible amount is used to represent the range of values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * that are currently visible.  The size of the scroll bar's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * bubble (also called a thumb or scroll box), usually gives a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * visual representation of the relationship of the visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * amount to the range of the scroll bar.
7000
5ddef688a02d 6659228: GridBagConstraints API typo - 'ComponentOrienation' (missing t)
dav
parents: 5506
diff changeset
   670
     * Note that depending on platform, the value of the visible amount property
5ddef688a02d 6659228: GridBagConstraints API typo - 'ComponentOrienation' (missing t)
dav
parents: 5506
diff changeset
   671
     * may not be visually indicated by the size of the bubble.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * The scroll bar's bubble may not be displayed when it is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * moveable (e.g. when it takes up the entire length of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * scroll bar's track, or when the scroll bar is disabled).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * Whether the bubble is displayed or not will not affect
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   677
     * the value returned by {@code getVisibleAmount}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   679
     * If the visible amount supplied is less than {@code one}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   680
     * or greater than the current {@code maximum - minimum},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   681
     * then either {@code one} or {@code maximum - minimum}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * is substituted, as appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * Normally, a program should change a scroll bar's
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   685
     * value only by calling {@code setValues}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   686
     * The {@code setValues} method simultaneously
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * and synchronously sets the minimum, maximum, visible amount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * and value properties of a scroll bar, so that they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * mutually consistent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * @param       newAmount the new visible amount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * @see         java.awt.Scrollbar#getVisibleAmount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * @see         java.awt.Scrollbar#setValues
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   694
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    public void setVisibleAmount(int newAmount) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        // Use setValues so that a consistent policy relating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        // minimum, maximum, visible amount, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        setValues(value, newAmount, minimum, maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * Sets the unit increment for this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * The unit increment is the value that is added or subtracted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * when the user activates the unit increment area of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * scroll bar, generally through a mouse or keyboard gesture
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * that the scroll bar receives as an adjustment event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * The unit increment must be greater than zero.
26749
b6598aa90114 8055326: Fix typos in client-related packages
serb
parents: 25859
diff changeset
   710
     * Attempts to set the unit increment to a value lower than 1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * will result in a value of 1 being set.
20120
e89bfc3f8d0e 7057770: (spec)Scrollbar spec should specify that unit increment & decrement functionality may not be present
malenkov
parents: 15318
diff changeset
   712
     * <p>
e89bfc3f8d0e 7057770: (spec)Scrollbar spec should specify that unit increment & decrement functionality may not be present
malenkov
parents: 15318
diff changeset
   713
     * In some operating systems, this property
e89bfc3f8d0e 7057770: (spec)Scrollbar spec should specify that unit increment & decrement functionality may not be present
malenkov
parents: 15318
diff changeset
   714
     * can be ignored by the underlying controls.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * @param        v  the amount by which to increment or decrement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     *                         the scroll bar's value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * @see          java.awt.Scrollbar#getUnitIncrement
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   719
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    public void setUnitIncrement(int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        setLineIncrement(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   726
     * Sets the unit increment for this scroll bar.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   727
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   728
     * @param  v the increment value
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   729
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   731
     * replaced by {@code setUnitIncrement(int)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    public synchronized void setLineIncrement(int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        int tmp = (v < 1) ? 1 : v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        if (lineIncrement == tmp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        lineIncrement = tmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        ScrollbarPeer peer = (ScrollbarPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            peer.setLineIncrement(lineIncrement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     * Gets the unit increment for this scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * The unit increment is the value that is added or subtracted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * when the user activates the unit increment area of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     * scroll bar, generally through a mouse or keyboard gesture
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
     * that the scroll bar receives as an adjustment event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
     * The unit increment must be greater than zero.
20120
e89bfc3f8d0e 7057770: (spec)Scrollbar spec should specify that unit increment & decrement functionality may not be present
malenkov
parents: 15318
diff changeset
   756
     * <p>
e89bfc3f8d0e 7057770: (spec)Scrollbar spec should specify that unit increment & decrement functionality may not be present
malenkov
parents: 15318
diff changeset
   757
     * In some operating systems, this property
e89bfc3f8d0e 7057770: (spec)Scrollbar spec should specify that unit increment & decrement functionality may not be present
malenkov
parents: 15318
diff changeset
   758
     * can be ignored by the underlying controls.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     * @return      the unit increment of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     * @see         java.awt.Scrollbar#setUnitIncrement
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   762
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    public int getUnitIncrement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        return getLineIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   769
     * Returns the unit increment for this scrollbar.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   770
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   771
     * @return the unit increment for this scrollbar
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   773
     * replaced by {@code getUnitIncrement()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    public int getLineIncrement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        return lineIncrement;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * Sets the block increment for this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * The block increment is the value that is added or subtracted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * when the user activates the block increment area of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     * scroll bar, generally through a mouse or keyboard gesture
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * that the scroll bar receives as an adjustment event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     * The block increment must be greater than zero.
26749
b6598aa90114 8055326: Fix typos in client-related packages
serb
parents: 25859
diff changeset
   788
     * Attempts to set the block increment to a value lower than 1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * will result in a value of 1 being set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * @param        v  the amount by which to increment or decrement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     *                         the scroll bar's value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * @see          java.awt.Scrollbar#getBlockIncrement
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   794
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    public void setBlockIncrement(int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        setPageIncrement(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   801
     * Sets the block increment for this scroll bar.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   802
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   803
     * @param  v the block increment
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   805
     * replaced by {@code setBlockIncrement()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    public synchronized void setPageIncrement(int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        int tmp = (v < 1) ? 1 : v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        if (pageIncrement == tmp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        pageIncrement = tmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        ScrollbarPeer peer = (ScrollbarPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
            peer.setPageIncrement(pageIncrement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * Gets the block increment of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     * The block increment is the value that is added or subtracted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * when the user activates the block increment area of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * scroll bar, generally through a mouse or keyboard gesture
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     * that the scroll bar receives as an adjustment event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * The block increment must be greater than zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * @return      the block increment of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * @see         java.awt.Scrollbar#setBlockIncrement
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   833
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    public int getBlockIncrement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        return getPageIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   840
     * Returns the block increment of this scroll bar.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   841
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   842
     * @return the block increment of this scroll bar
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   843
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   845
     * replaced by {@code getBlockIncrement()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    public int getPageIncrement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        return pageIncrement;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * Sets the values of four properties for this scroll bar:
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   854
     * {@code value}, {@code visibleAmount},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   855
     * {@code minimum}, and {@code maximum}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
     * If the values supplied for these properties are inconsistent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
     * or incorrect, they will be changed to ensure consistency.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
     * This method simultaneously and synchronously sets the values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     * of four scroll bar properties, assuring that the values of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     * these properties are mutually consistent. It enforces the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
     * following constraints:
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   863
     * {@code maximum} must be greater than {@code minimum},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   864
     * {@code maximum - minimum} must not be greater
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   865
     *     than {@code Integer.MAX_VALUE},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   866
     * {@code visibleAmount} must be greater than zero.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   867
     * {@code visibleAmount} must not be greater than
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   868
     *     {@code maximum - minimum},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   869
     * {@code value} must not be less than {@code minimum},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   870
     * and {@code value} must not be greater than
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   871
     *     {@code maximum - visibleAmount}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
     * Calling this method does not fire an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   874
     * {@code AdjustmentEvent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     * @param      value is the position in the current window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     * @param      visible is the visible amount of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     * @param      minimum is the minimum value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     * @param      maximum is the maximum value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
     * @see        #setMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     * @see        #setMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     * @see        #setVisibleAmount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
     * @see        #setValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    public void setValues(int value, int visible, int minimum, int maximum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        int oldValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
            if (minimum == Integer.MAX_VALUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
                minimum = Integer.MAX_VALUE - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
            if (maximum <= minimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                maximum = minimum + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
            long maxMinusMin = (long) maximum - (long) minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
            if (maxMinusMin > Integer.MAX_VALUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
                maxMinusMin = Integer.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
                maximum = minimum + (int) maxMinusMin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
            if (visible > (int) maxMinusMin) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
                visible = (int) maxMinusMin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
            if (visible < 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
                visible = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            if (value < minimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
                value = minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            if (value > maximum - visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                value = maximum - visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            oldValue = this.value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
            this.value = value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
            this.visibleAmount = visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
            this.minimum = minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
            this.maximum = maximum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
            ScrollbarPeer peer = (ScrollbarPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                peer.setValues(value, visibleAmount, minimum, maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        if ((oldValue != value) && (accessibleContext != null))  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            accessibleContext.firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                    AccessibleContext.ACCESSIBLE_VALUE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
                    Integer.valueOf(oldValue),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
                    Integer.valueOf(value));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     * Returns true if the value is in the process of changing as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     * result of actions being taken by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   937
     * @return the value of the {@code valueIsAdjusting} property
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     * @see #setValueIsAdjusting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
    public boolean getValueIsAdjusting() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        return isAdjusting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   946
     * Sets the {@code valueIsAdjusting} property.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
     * @param b new adjustment-in-progress status
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * @see #getValueIsAdjusting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    public void setValueIsAdjusting(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        boolean oldValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
            oldValue = isAdjusting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
            isAdjusting = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        if ((oldValue != b) && (accessibleContext != null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
            accessibleContext.firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                    AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                    ((oldValue) ? AccessibleState.BUSY : null),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
                    ((b) ? AccessibleState.BUSY : null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
     * Adds the specified adjustment listener to receive instances of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   972
     * {@code AdjustmentEvent} from this scroll bar.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   973
     * If l is {@code null}, no exception is thrown and no
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     * action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
     * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * >AWT Threading Issues</a> for details on AWT's threading model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     * @param        l the adjustment listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     * @see          #removeAdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * @see          #getAdjustmentListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * @see          java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     * @see          java.awt.event.AdjustmentListener
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   983
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
    public synchronized void addAdjustmentListener(AdjustmentListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
        if (l == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
        adjustmentListener = AWTEventMulticaster.add(adjustmentListener, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
        newEventsOnly = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     * Removes the specified adjustment listener so that it no longer
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   995
     * receives instances of {@code AdjustmentEvent} from this scroll bar.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   996
     * If l is {@code null}, no exception is thrown and no action
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     * is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * >AWT Threading Issues</a> for details on AWT's threading model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * @param           l    the adjustment listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     * @see             #addAdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     * @see             #getAdjustmentListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     * @see             java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     * @see             java.awt.event.AdjustmentListener
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
  1006
     * @since           1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    public synchronized void removeAdjustmentListener(AdjustmentListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        if (l == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
        adjustmentListener = AWTEventMulticaster.remove(adjustmentListener, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
     * Returns an array of all the adjustment listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     * registered on this scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1019
     * @return all of this scrollbar's {@code AdjustmentListener}s
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
     *         or an empty array if no adjustment
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     *         listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     * @see             #addAdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * @see             #removeAdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * @see             java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * @see             java.awt.event.AdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
    public synchronized AdjustmentListener[] getAdjustmentListeners() {
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 7668
diff changeset
  1029
        return getListeners(AdjustmentListener.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     * Returns an array of all the objects currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     * as <code><em>Foo</em>Listener</code>s
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1035
     * upon this {@code Scrollbar}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
     * <code><em>Foo</em>Listener</code>s are registered using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
     * <code>add<em>Foo</em>Listener</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1039
     * You can specify the {@code listenerType} argument
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     * with a class literal,  such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     * <code><em>Foo</em>Listener.class</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     * For example, you can query a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1043
     * {@code Scrollbar c}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     * for its mouse listeners with the following code:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     * <pre>MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class));</pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
     * If no such listeners exist, this method returns an empty array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     * @param listenerType the type of listeners requested; this parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
     *          should specify an interface that descends from
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1052
     *          {@code java.util.EventListener}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
     * @return an array of all objects registered as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
     *          <code><em>Foo</em>Listener</code>s on this component,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     *          or an empty array if no such listeners have been added
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1056
     * @exception ClassCastException if {@code listenerType}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
     *          doesn't specify a class or interface that implements
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1058
     *          {@code java.util.EventListener}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
    public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
        EventListener l = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
        if  (listenerType == AdjustmentListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
            l = adjustmentListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
            return super.getListeners(listenerType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
        return AWTEventMulticaster.getListeners(l, listenerType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
    // REMIND: remove when filtering is done at lower level
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
    boolean eventEnabled(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
        if (e.id == AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
            if ((eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                adjustmentListener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
        return super.eventEnabled(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
     * Processes events on this scroll bar. If the event is an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1086
     * instance of {@code AdjustmentEvent}, it invokes the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1087
     * {@code processAdjustmentEvent} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
     * Otherwise, it invokes its superclass's
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1089
     * {@code processEvent} method.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1090
     * <p>Note that if the event parameter is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
     * the behavior is unspecified and may result in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
     * exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
     * @param        e the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
     * @see          java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
     * @see          java.awt.Scrollbar#processAdjustmentEvent
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
  1097
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
    protected void processEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
        if (e instanceof AdjustmentEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
            processAdjustmentEvent((AdjustmentEvent)e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
        super.processEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
     * Processes adjustment events occurring on this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
     * scrollbar by dispatching them to any registered
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1110
     * {@code AdjustmentListener} objects.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
     * This method is not called unless adjustment events are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
     * enabled for this component. Adjustment events are enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
     * when one of the following occurs:
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 20451
diff changeset
  1115
     * <ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1116
     * <li>An {@code AdjustmentListener} object is registered
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1117
     * via {@code addAdjustmentListener}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1118
     * <li>Adjustment events are enabled via {@code enableEvents}.
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 20451
diff changeset
  1119
     * </ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1120
     * <p>Note that if the event parameter is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
     * the behavior is unspecified and may result in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     * exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     * @param       e the adjustment event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * @see         java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     * @see         java.awt.event.AdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * @see         java.awt.Scrollbar#addAdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
     * @see         java.awt.Component#enableEvents
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
  1129
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
    protected void processAdjustmentEvent(AdjustmentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
        AdjustmentListener listener = adjustmentListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
        if (listener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
            listener.adjustmentValueChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1139
     * Returns a string representing the state of this {@code Scrollbar}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
     * This method is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
     * implementations. The returned string may be empty but may not be
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1143
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
     * @return      the parameter string of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
        return super.paramString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
            ",val=" + value +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
            ",vis=" + visibleAmount +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
            ",min=" + minimum +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
            ",max=" + maximum +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
            ((orientation == VERTICAL) ? ",vert" : ",horz") +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
            ",isAdjusting=" + isAdjusting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
    /* Serialization support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
     * The scroll bar's serialized Data Version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
    private int scrollbarSerializedDataVersion = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
     * Writes default serializable fields to stream.  Writes
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1170
     * a list of serializable {@code AdjustmentListeners}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
     * as optional data. The non-serializable listeners are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
     * detected and no attempt is made to serialize them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1174
     * @param s the {@code ObjectOutputStream} to write
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1175
     * @serialData {@code null} terminated sequence of 0
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1176
     *   or more pairs; the pair consists of a {@code String}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1177
     *   and an {@code Object}; the {@code String} indicates
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
     *   the type of object and is one of the following:
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1179
     *   {@code adjustmentListenerK} indicating an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1180
     *     {@code AdjustmentListener} object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
     * @see AWTEventMulticaster#save(ObjectOutputStream, String, EventListener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
     * @see java.awt.Component#adjustmentListenerK
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
     * @see #readObject(ObjectInputStream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
    private void writeObject(ObjectOutputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
      throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
      s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
      AWTEventMulticaster.save(s, adjustmentListenerK, adjustmentListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
      s.writeObject(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1196
     * Reads the {@code ObjectInputStream} and if
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1197
     * it isn't {@code null} adds a listener to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
     * receive adjustment events fired by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1199
     * {@code Scrollbar}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
     * Unrecognized keys or values will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1202
     * @param s the {@code ObjectInputStream} to read
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
     * @exception HeadlessException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1204
     *   {@code GraphicsEnvironment.isHeadless} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1205
     *   {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
     * @see #writeObject(ObjectOutputStream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
      throws ClassNotFoundException, IOException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
      GraphicsEnvironment.checkHeadless();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
      s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
      Object keyOrNull;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
      while(null != (keyOrNull = s.readObject())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
        String key = ((String)keyOrNull).intern();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
        if (adjustmentListenerK == key)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
          addAdjustmentListener((AdjustmentListener)(s.readObject()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
        else // skip value for unrecognized key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
          s.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1233
     * Gets the {@code AccessibleContext} associated with this
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1234
     * {@code Scrollbar}. For scrollbars, the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1235
     * {@code AccessibleContext} takes the form of an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1236
     * {@code AccessibleAWTScrollBar}. A new
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1237
     * {@code AccessibleAWTScrollBar} instance is created if necessary.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1239
     * @return an {@code AccessibleAWTScrollBar} that serves as the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1240
     *         {@code AccessibleContext} of this {@code ScrollBar}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
            accessibleContext = new AccessibleAWTScrollBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
     * This class implements accessibility support for the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1252
     * {@code Scrollbar} class.  It provides an implementation of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
     * the Java Accessibility API appropriate to scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
     * user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
    protected class AccessibleAWTScrollBar extends AccessibleAWTComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
        implements AccessibleValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
         * JDK 1.3 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
        private static final long serialVersionUID = -344337268523697807L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
         * Get the state set of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1268
         * @return an instance of {@code AccessibleState}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
         *     containing the current state of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
            if (getValueIsAdjusting()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
                states.add(AccessibleState.BUSY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
            if (getOrientation() == VERTICAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
                states.add(AccessibleState.VERTICAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
                states.add(AccessibleState.HORIZONTAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1288
         * @return an instance of {@code AccessibleRole}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
         *     describing the role of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
            return AccessibleRole.SCROLL_BAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1296
         * Get the {@code AccessibleValue} associated with this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
         * object.  In the implementation of the Java Accessibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
         * API for this class, return this object, which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
         * responsible for implementing the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1300
         * {@code AccessibleValue} interface on behalf of itself.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
         * @return this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
        public AccessibleValue getAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
         * Get the accessible value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
         * @return The current value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
        public Number getCurrentAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
            return Integer.valueOf(getValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
         * Set the value of this object as a Number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
         * @return True if the value was set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
        public boolean setCurrentAccessibleValue(Number n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
            if (n instanceof Integer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
                setValue(n.intValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
         * Get the minimum accessible value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
         * @return The minimum value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
        public Number getMinimumAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
            return Integer.valueOf(getMinimum());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
         * Get the maximum accessible value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
         * @return The maximum value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
        public Number getMaximumAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
            return Integer.valueOf(getMaximum());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
    } // AccessibleAWTScrollBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
}