jdk/src/java.desktop/share/classes/java/awt/Scrollbar.java
author serb
Thu, 08 Jun 2017 22:07:08 -0700
changeset 45648 87c997b74bb8
parent 35667 ed476aba94de
permissions -rw-r--r--
8180326: Update the tables in java.desktop to be HTML-5 friendly Reviewed-by: prr, azvegint
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
45648
87c997b74bb8 8180326: Update the tables in java.desktop to be HTML-5 friendly
serb
parents: 35667
diff changeset
     2
 * Copyright (c) 1995, 2017, 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>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <img src="doc-files/Scrollbar-1.gif" alt="Image shows 3 vertical sliders, side-by-side."
20451
4cedf4e1560a 8025409: Fix javadoc comments errors and warning reported by doclint report
cl
parents: 20120
diff changeset
    45
 * style="float:center; 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"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * alt="Image shows horizontal slider with starting range of 0 and ending range of 300. The slider thumb is labeled 60."
20451
4cedf4e1560a 8025409: Fix javadoc comments errors and warning reported by doclint report
cl
parents: 20120
diff changeset
    63
 * style="float:center; 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>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     *   <th>Property</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *   <th>Description</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *   <th>Default Value</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * </tr>
45648
87c997b74bb8 8180326: Update the tables in java.desktop to be HTML-5 friendly
serb
parents: 35667
diff changeset
   307
     * </thead>
87c997b74bb8 8180326: Update the tables in java.desktop to be HTML-5 friendly
serb
parents: 35667
diff changeset
   308
     * <tbody>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     *   <td>orientation</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     *   <td>indicates whether the scroll bar is vertical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *   <br>or horizontal</td>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   313
     *   <td>{@code Scrollbar.VERTICAL}</td>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     *   <td>value</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     *   <td>value which controls the location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     *   <br>of the scroll bar's bubble</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *   <td>0</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     *   <td>visible amount</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *   <td>visible amount of the scroll bar's range,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *   <br>typically represented by the size of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     *   <br>scroll bar's bubble</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *   <td>10</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *   <td>minimum</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *   <td>minimum value of the scroll bar</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *   <td>0</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *   <td>maximum</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *   <td>maximum value of the scroll bar</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     *   <td>100</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *   <td>unit increment</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *   <td>amount the value changes when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     *   <br>Line Up or Line Down key is pressed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *   <br>or when the end arrows of the scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *   <br>are clicked </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *   <td>1</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     *   <td>block increment</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *   <td>amount the value changes when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *   <br>Page Up or Page Down key is pressed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *   <br>or when the scrollbar track is clicked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     *   <br>on either side of the bubble </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *   <td>10</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * </tr>
45648
87c997b74bb8 8180326: Update the tables in java.desktop to be HTML-5 friendly
serb
parents: 35667
diff changeset
   354
     * </tbody>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    public Scrollbar() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        this(VERTICAL, 0, 10, 0, 100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * Constructs a new scroll bar with the specified orientation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   368
     * The {@code orientation} argument must take one of the two
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   369
     * values {@code Scrollbar.HORIZONTAL},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   370
     * or {@code Scrollbar.VERTICAL},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * indicating a horizontal or vertical scroll bar, respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @param       orientation   indicates the orientation of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @exception   IllegalArgumentException    when an illegal value for
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   375
     *                    the {@code orientation} argument is supplied
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    public Scrollbar(int orientation) throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        this(orientation, 0, 10, 0, 100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * Constructs a new scroll bar with the specified orientation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * initial value, visible amount, and minimum and maximum values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   388
     * The {@code orientation} argument must take one of the two
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   389
     * values {@code Scrollbar.HORIZONTAL},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   390
     * or {@code Scrollbar.VERTICAL},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * indicating a horizontal or vertical scroll bar, respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * The parameters supplied to this constructor are subject to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * constraints described in {@link #setValues(int, int, int, int)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * @param     orientation   indicates the orientation of the scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @param     value     the initial value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * @param     visible   the visible amount of the scroll bar, typically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     *                      represented by the size of the bubble
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @param     minimum   the minimum value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @param     maximum   the maximum value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @exception IllegalArgumentException    when an illegal value for
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   403
     *                    the {@code orientation} argument is supplied
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * @see #setValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    public Scrollbar(int orientation, int value, int visible, int minimum,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        int maximum) throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        GraphicsEnvironment.checkHeadless();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        switch (orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
          case HORIZONTAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
          case VERTICAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            this.orientation = orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            throw new IllegalArgumentException("illegal scrollbar orientation");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        setValues(value, visible, minimum, maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   424
     * Constructs a name for this component.  Called by {@code getName}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   425
     * when the name is {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    String constructComponentName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        synchronized (Scrollbar.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            return base + nameCounter++;
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
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   434
     * Creates the {@code Scrollbar}'s peer.  The peer allows you to modify
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   435
     * the appearance of the {@code Scrollbar} without changing any of its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            if (peer == null)
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
   441
                peer = getComponentFactory().createScrollbar(this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            super.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * Returns the orientation of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * @return    the orientation of this scroll bar, either
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   450
     *               {@code Scrollbar.HORIZONTAL} or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   451
     *               {@code Scrollbar.VERTICAL}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * @see       java.awt.Scrollbar#setOrientation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    public int getOrientation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        return orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * Sets the orientation for this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * @param orientation  the orientation of this scroll bar, either
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   462
     *               {@code Scrollbar.HORIZONTAL} or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   463
     *               {@code Scrollbar.VERTICAL}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @see       java.awt.Scrollbar#getOrientation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @exception   IllegalArgumentException  if the value supplied
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   466
     *                   for {@code orientation} is not a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *                   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
   468
     * @since     1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    public void setOrientation(int orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            if (orientation == this.orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            switch (orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                case HORIZONTAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                case VERTICAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                    this.orientation = orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                    throw new IllegalArgumentException("illegal scrollbar orientation");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            /* Create a new peer with the specified orientation. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                removeNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        if (accessibleContext != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            accessibleContext.firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                    AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
                    ((orientation == VERTICAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
                     ? AccessibleState.HORIZONTAL : AccessibleState.VERTICAL),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                    ((orientation == VERTICAL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
                     ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * Gets the current value of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @return      the current value of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * @see         java.awt.Scrollbar#getMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * @see         java.awt.Scrollbar#getMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    public int getValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * Sets the value of this scroll bar to the specified value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   514
     * If the value supplied is less than the current {@code minimum}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   515
     * or greater than the current {@code maximum - visibleAmount},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   516
     * then either {@code minimum} or {@code maximum - visibleAmount}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * is substituted, as appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * Normally, a program should change a scroll bar's
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   520
     * value only by calling {@code setValues}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   521
     * The {@code setValues} method simultaneously
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * and synchronously sets the minimum, maximum, visible amount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * and value properties of a scroll bar, so that they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * mutually consistent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * Calling this method does not fire an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   527
     * {@code AdjustmentEvent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * @param       newValue   the new value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * @see         java.awt.Scrollbar#setValues
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#getMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @see         java.awt.Scrollbar#getMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    public void setValue(int newValue) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        // Use setValues so that a consistent policy relating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        // minimum, maximum, visible amount, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        setValues(newValue, visibleAmount, minimum, maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * Gets the minimum value of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * @return      the minimum value of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * @see         java.awt.Scrollbar#getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * @see         java.awt.Scrollbar#getMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    public int getMinimum() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        return minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * Sets the minimum value of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   555
     * When {@code setMinimum} is called, the minimum value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * is changed, and other values (including the maximum, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * visible amount, and the current scroll bar value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * are changed to be consistent with the new minimum.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * Normally, a program should change a scroll bar's minimum
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   561
     * value only by calling {@code setValues}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   562
     * The {@code setValues} method simultaneously
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * and synchronously sets the minimum, maximum, visible amount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * and value properties of a scroll bar, so that they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * mutually consistent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   567
     * Note that setting the minimum value to {@code Integer.MAX_VALUE}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * will result in the new minimum value being set to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   569
     * {@code Integer.MAX_VALUE - 1}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * @param       newMinimum   the new minimum value for this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * @see         java.awt.Scrollbar#setValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * @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
   574
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    public void setMinimum(int newMinimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        // No checks are necessary in this method since minimum is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        // the first variable checked in the setValues function.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        // Use setValues so that a consistent policy relating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        // minimum, maximum, visible amount, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        setValues(value, visibleAmount, newMinimum, maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * Gets the maximum value of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * @return      the maximum value of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * @see         java.awt.Scrollbar#getValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * @see         java.awt.Scrollbar#getMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    public int getMaximum() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        return maximum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * Sets the maximum value of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   599
     * When {@code setMaximum} is called, the maximum value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * is changed, and other values (including the minimum, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * visible amount, and the current scroll bar value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * are changed to be consistent with the new maximum.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * Normally, a program should change a scroll bar's maximum
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   605
     * value only by calling {@code setValues}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   606
     * The {@code setValues} method simultaneously
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * and synchronously sets the minimum, maximum, visible amount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * and value properties of a scroll bar, so that they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * mutually consistent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   611
     * Note that setting the maximum value to {@code Integer.MIN_VALUE}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * will result in the new maximum value being set to
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   613
     * {@code Integer.MIN_VALUE + 1}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * @param       newMaximum   the new maximum value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     *                     for this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * @see         java.awt.Scrollbar#setValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * @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
   619
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    public void setMaximum(int newMaximum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        // minimum is checked first in setValues, so we need to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        // enforce minimum and maximum checks here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        if (newMaximum == Integer.MIN_VALUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            newMaximum = Integer.MIN_VALUE + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        if (minimum >= newMaximum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            minimum = newMaximum - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        // Use setValues so that a consistent policy relating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        // minimum, maximum, visible amount, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        setValues(value, visibleAmount, minimum, newMaximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * Gets the visible amount of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * When a scroll bar is used to select a range of values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * the visible amount is used to represent the range of values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * that are currently visible.  The size of the scroll bar's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * bubble (also called a thumb or scroll box), usually gives a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * visual representation of the relationship of the visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * amount to the range of the scroll bar.
7000
5ddef688a02d 6659228: GridBagConstraints API typo - 'ComponentOrienation' (missing t)
dav
parents: 5506
diff changeset
   646
     * 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
   647
     * may not be visually indicated by the size of the bubble.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * The scroll bar's bubble may not be displayed when it is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * moveable (e.g. when it takes up the entire length of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * scroll bar's track, or when the scroll bar is disabled).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * Whether the bubble is displayed or not will not affect
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   653
     * the value returned by {@code getVisibleAmount}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * @return      the visible amount of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * @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
   657
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    public int getVisibleAmount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        return getVisible();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   664
     * Returns the visible amount of this scroll bar.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   665
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   666
     * @return the visible amount of this scroll bar
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   668
     * replaced by {@code getVisibleAmount()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    public int getVisible() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        return visibleAmount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * Sets the visible amount of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * When a scroll bar is used to select a range of values,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * the visible amount is used to represent the range of values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * that are currently visible.  The size of the scroll bar's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * bubble (also called a thumb or scroll box), usually gives a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * visual representation of the relationship of the visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * amount to the range of the scroll bar.
7000
5ddef688a02d 6659228: GridBagConstraints API typo - 'ComponentOrienation' (missing t)
dav
parents: 5506
diff changeset
   684
     * 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
   685
     * may not be visually indicated by the size of the bubble.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * The scroll bar's bubble may not be displayed when it is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * moveable (e.g. when it takes up the entire length of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * scroll bar's track, or when the scroll bar is disabled).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * Whether the bubble is displayed or not will not affect
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   691
     * the value returned by {@code getVisibleAmount}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   693
     * If the visible amount supplied is less than {@code one}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   694
     * or greater than the current {@code maximum - minimum},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   695
     * then either {@code one} or {@code maximum - minimum}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * is substituted, as appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * Normally, a program should change a scroll bar's
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   699
     * value only by calling {@code setValues}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   700
     * The {@code setValues} method simultaneously
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * and synchronously sets the minimum, maximum, visible amount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * and value properties of a scroll bar, so that they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * mutually consistent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * @param       newAmount the new visible amount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * @see         java.awt.Scrollbar#getVisibleAmount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * @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
   708
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    public void setVisibleAmount(int newAmount) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        // Use setValues so that a consistent policy relating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        // minimum, maximum, visible amount, and value is enforced.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        setValues(value, newAmount, minimum, maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * Sets the unit increment for this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * The unit increment is the value that is added or subtracted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * when the user activates the unit increment area of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * scroll bar, generally through a mouse or keyboard gesture
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * that the scroll bar receives as an adjustment event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * The unit increment must be greater than zero.
26749
b6598aa90114 8055326: Fix typos in client-related packages
serb
parents: 25859
diff changeset
   724
     * Attempts to set the unit increment to a value lower than 1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * 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
   726
     * <p>
e89bfc3f8d0e 7057770: (spec)Scrollbar spec should specify that unit increment & decrement functionality may not be present
malenkov
parents: 15318
diff changeset
   727
     * 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
   728
     * can be ignored by the underlying controls.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * @param        v  the amount by which to increment or decrement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     *                         the scroll bar's value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * @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
   733
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    public void setUnitIncrement(int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        setLineIncrement(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   740
     * Sets the unit increment for this scroll bar.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   741
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   742
     * @param  v the increment value
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   743
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   745
     * replaced by {@code setUnitIncrement(int)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    public synchronized void setLineIncrement(int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        int tmp = (v < 1) ? 1 : v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        if (lineIncrement == tmp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        lineIncrement = tmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        ScrollbarPeer peer = (ScrollbarPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
            peer.setLineIncrement(lineIncrement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     * Gets the unit increment for this scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * The unit increment is the value that is added or subtracted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * when the user activates the unit increment area of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * scroll bar, generally through a mouse or keyboard gesture
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     * that the scroll bar receives as an adjustment event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     * 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
   770
     * <p>
e89bfc3f8d0e 7057770: (spec)Scrollbar spec should specify that unit increment & decrement functionality may not be present
malenkov
parents: 15318
diff changeset
   771
     * 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
   772
     * can be ignored by the underlying controls.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * @return      the unit increment of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * @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
   776
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    public int getUnitIncrement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        return getLineIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   783
     * Returns the unit increment for this scrollbar.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   784
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   785
     * @return the unit increment for this scrollbar
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   787
     * replaced by {@code getUnitIncrement()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    public int getLineIncrement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        return lineIncrement;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * Sets the block increment for this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * The block increment is the value that is added or subtracted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * when the user activates the block increment area of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * scroll bar, generally through a mouse or keyboard gesture
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * that the scroll bar receives as an adjustment event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * The block increment must be greater than zero.
26749
b6598aa90114 8055326: Fix typos in client-related packages
serb
parents: 25859
diff changeset
   802
     * Attempts to set the block increment to a value lower than 1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     * will result in a value of 1 being set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * @param        v  the amount by which to increment or decrement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     *                         the scroll bar's value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     * @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
   808
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    public void setBlockIncrement(int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        setPageIncrement(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   815
     * Sets the block increment for this scroll bar.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   816
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   817
     * @param  v the block increment
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   819
     * replaced by {@code setBlockIncrement()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    public synchronized void setPageIncrement(int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        int tmp = (v < 1) ? 1 : v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        if (pageIncrement == tmp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        pageIncrement = tmp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        ScrollbarPeer peer = (ScrollbarPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
            peer.setPageIncrement(pageIncrement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     * Gets the block increment of this scroll bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * The block increment is the value that is added or subtracted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * when the user activates the block increment area of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * scroll bar, generally through a mouse or keyboard gesture
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * that the scroll bar receives as an adjustment event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     * The block increment must be greater than zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * @return      the block increment of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     * @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
   847
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    public int getBlockIncrement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        return getPageIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   854
     * Returns the block increment of this scroll bar.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   855
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   856
     * @return the block increment of this scroll bar
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
   857
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   859
     * replaced by {@code getBlockIncrement()}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    public int getPageIncrement() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        return pageIncrement;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     * Sets the values of four properties for this scroll bar:
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   868
     * {@code value}, {@code visibleAmount},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   869
     * {@code minimum}, and {@code maximum}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     * If the values supplied for these properties are inconsistent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     * or incorrect, they will be changed to ensure consistency.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
     * This method simultaneously and synchronously sets the values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     * of four scroll bar properties, assuring that the values of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     * these properties are mutually consistent. It enforces the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     * following constraints:
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   877
     * {@code maximum} must be greater than {@code minimum},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   878
     * {@code maximum - minimum} must not be greater
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   879
     *     than {@code Integer.MAX_VALUE},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   880
     * {@code visibleAmount} must be greater than zero.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   881
     * {@code visibleAmount} must not be greater than
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   882
     *     {@code maximum - minimum},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   883
     * {@code value} must not be less than {@code minimum},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   884
     * and {@code value} must not be greater than
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   885
     *     {@code maximum - visibleAmount}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
     * Calling this method does not fire an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   888
     * {@code AdjustmentEvent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
     * @param      value is the position in the current window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     * @param      visible is the visible amount of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     * @param      minimum is the minimum value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     * @param      maximum is the maximum value of the scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * @see        #setMinimum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     * @see        #setMaximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * @see        #setVisibleAmount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     * @see        #setValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    public void setValues(int value, int visible, int minimum, int maximum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        int oldValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
            if (minimum == Integer.MAX_VALUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
                minimum = Integer.MAX_VALUE - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            if (maximum <= minimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                maximum = minimum + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            long maxMinusMin = (long) maximum - (long) minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
            if (maxMinusMin > Integer.MAX_VALUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                maxMinusMin = Integer.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
                maximum = minimum + (int) maxMinusMin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            if (visible > (int) maxMinusMin) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                visible = (int) maxMinusMin;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
            if (visible < 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                visible = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
            if (value < minimum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                value = minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
            if (value > maximum - visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                value = maximum - visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
            oldValue = this.value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            this.value = value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
            this.visibleAmount = visible;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
            this.minimum = minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            this.maximum = maximum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            ScrollbarPeer peer = (ScrollbarPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                peer.setValues(value, visibleAmount, minimum, maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        if ((oldValue != value) && (accessibleContext != null))  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
            accessibleContext.firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                    AccessibleContext.ACCESSIBLE_VALUE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
                    Integer.valueOf(oldValue),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                    Integer.valueOf(value));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
     * Returns true if the value is in the process of changing as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * result of actions being taken by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   951
     * @return the value of the {@code valueIsAdjusting} property
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * @see #setValueIsAdjusting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
    public boolean getValueIsAdjusting() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        return isAdjusting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   960
     * Sets the {@code valueIsAdjusting} property.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     * @param b new adjustment-in-progress status
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     * @see #getValueIsAdjusting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
    public void setValueIsAdjusting(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        boolean oldValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
            oldValue = isAdjusting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
            isAdjusting = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
        if ((oldValue != b) && (accessibleContext != null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
            accessibleContext.firePropertyChange(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
                    AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
                    ((oldValue) ? AccessibleState.BUSY : null),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                    ((b) ? AccessibleState.BUSY : null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     * Adds the specified adjustment listener to receive instances of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   986
     * {@code AdjustmentEvent} from this scroll bar.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   987
     * If l is {@code null}, no exception is thrown and no
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * action is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     * >AWT Threading Issues</a> for details on AWT's threading model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     * @param        l the adjustment listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     * @see          #removeAdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     * @see          #getAdjustmentListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
     * @see          java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * @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
   997
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
    public synchronized void addAdjustmentListener(AdjustmentListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
        if (l == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        adjustmentListener = AWTEventMulticaster.add(adjustmentListener, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        newEventsOnly = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     * Removes the specified adjustment listener so that it no longer
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1009
     * receives instances of {@code AdjustmentEvent} from this scroll bar.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1010
     * If l is {@code null}, no exception is thrown and no action
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     * is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
     * <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
     * >AWT Threading Issues</a> for details on AWT's threading model.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
     * @param           l    the adjustment listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
     * @see             #addAdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     * @see             #getAdjustmentListeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     * @see             java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
     * @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
  1020
     * @since           1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
    public synchronized void removeAdjustmentListener(AdjustmentListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
        if (l == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
        adjustmentListener = AWTEventMulticaster.remove(adjustmentListener, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     * Returns an array of all the adjustment listeners
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     * registered on this scrollbar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1033
     * @return all of this scrollbar's {@code AdjustmentListener}s
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     *         or an empty array if no adjustment
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
     *         listeners are currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
     * @see             #addAdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
     * @see             #removeAdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     * @see             java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     * @see             java.awt.event.AdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
    public synchronized AdjustmentListener[] getAdjustmentListeners() {
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 7668
diff changeset
  1043
        return getListeners(AdjustmentListener.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
     * Returns an array of all the objects currently registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
     * as <code><em>Foo</em>Listener</code>s
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1049
     * upon this {@code Scrollbar}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     * <code><em>Foo</em>Listener</code>s are registered using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
     * <code>add<em>Foo</em>Listener</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1053
     * You can specify the {@code listenerType} argument
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
     * with a class literal,  such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     * <code><em>Foo</em>Listener.class</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
     * For example, you can query a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1057
     * {@code Scrollbar c}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
     * for its mouse listeners with the following code:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     * <pre>MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class));</pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     * If no such listeners exist, this method returns an empty array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     * @param listenerType the type of listeners requested; this parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     *          should specify an interface that descends from
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1066
     *          {@code java.util.EventListener}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
     * @return an array of all objects registered as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
     *          <code><em>Foo</em>Listener</code>s on this component,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
     *          or an empty array if no such listeners have been added
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1070
     * @exception ClassCastException if {@code listenerType}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
     *          doesn't specify a class or interface that implements
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1072
     *          {@code java.util.EventListener}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
    public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
        EventListener l = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
        if  (listenerType == AdjustmentListener.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
            l = adjustmentListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
            return super.getListeners(listenerType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
        return AWTEventMulticaster.getListeners(l, listenerType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
    // REMIND: remove when filtering is done at lower level
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
    boolean eventEnabled(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        if (e.id == AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            if ((eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                adjustmentListener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
        return super.eventEnabled(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
     * Processes events on this scroll bar. If the event is an
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1100
     * instance of {@code AdjustmentEvent}, it invokes the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1101
     * {@code processAdjustmentEvent} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
     * Otherwise, it invokes its superclass's
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1103
     * {@code processEvent} method.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1104
     * <p>Note that if the event parameter is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
     * the behavior is unspecified and may result in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
     * exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
     * @param        e the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
     * @see          java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
     * @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
  1111
     * @since        1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
    protected void processEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
        if (e instanceof AdjustmentEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
            processAdjustmentEvent((AdjustmentEvent)e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
        super.processEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     * Processes adjustment events occurring on this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     * scrollbar by dispatching them to any registered
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1124
     * {@code AdjustmentListener} objects.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     * This method is not called unless adjustment events are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * enabled for this component. Adjustment events are enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
     * when one of the following occurs:
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 20451
diff changeset
  1129
     * <ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1130
     * <li>An {@code AdjustmentListener} object is registered
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1131
     * via {@code addAdjustmentListener}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1132
     * <li>Adjustment events are enabled via {@code enableEvents}.
21957
97758de70fbd 8028019: AWT Doclint warning/error cleanup
rriggs
parents: 20451
diff changeset
  1133
     * </ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1134
     * <p>Note that if the event parameter is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
     * the behavior is unspecified and may result in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
     * exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
     * @param       e the adjustment event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
     * @see         java.awt.event.AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
     * @see         java.awt.event.AdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
     * @see         java.awt.Scrollbar#addAdjustmentListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
     * @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
  1143
     * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
    protected void processAdjustmentEvent(AdjustmentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        AdjustmentListener listener = adjustmentListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
        if (listener != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
            listener.adjustmentValueChanged(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1153
     * Returns a string representing the state of this {@code Scrollbar}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
     * This method is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
     * implementations. The returned string may be empty but may not be
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1157
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
     * @return      the parameter string of this scroll bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
        return super.paramString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
            ",val=" + value +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
            ",vis=" + visibleAmount +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
            ",min=" + minimum +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
            ",max=" + maximum +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
            ((orientation == VERTICAL) ? ",vert" : ",horz") +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
            ",isAdjusting=" + isAdjusting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    /* Serialization support.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
     * The scroll bar's serialized Data Version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
    private int scrollbarSerializedDataVersion = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
     * Writes default serializable fields to stream.  Writes
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1184
     * a list of serializable {@code AdjustmentListeners}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
     * as optional data. The non-serializable listeners are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
     * detected and no attempt is made to serialize them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1188
     * @param s the {@code ObjectOutputStream} to write
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1189
     * @serialData {@code null} terminated sequence of 0
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1190
     *   or more pairs; the pair consists of a {@code String}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1191
     *   and an {@code Object}; the {@code String} indicates
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
     *   the type of object and is one of the following:
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1193
     *   {@code adjustmentListenerK} indicating an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1194
     *     {@code AdjustmentListener} object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
     * @see AWTEventMulticaster#save(ObjectOutputStream, String, EventListener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
     * @see java.awt.Component#adjustmentListenerK
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
     * @see #readObject(ObjectInputStream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
    private void writeObject(ObjectOutputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
      throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
      s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
      AWTEventMulticaster.save(s, adjustmentListenerK, adjustmentListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
      s.writeObject(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1210
     * Reads the {@code ObjectInputStream} and if
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1211
     * it isn't {@code null} adds a listener to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
     * receive adjustment events fired by the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1213
     * {@code Scrollbar}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
     * Unrecognized keys or values will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1216
     * @param s the {@code ObjectInputStream} to read
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
     * @exception HeadlessException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1218
     *   {@code GraphicsEnvironment.isHeadless} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1219
     *   {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
     * @see #writeObject(ObjectOutputStream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
      throws ClassNotFoundException, IOException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
      GraphicsEnvironment.checkHeadless();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
      s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
      Object keyOrNull;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
      while(null != (keyOrNull = s.readObject())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
        String key = ((String)keyOrNull).intern();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
        if (adjustmentListenerK == key)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
          addAdjustmentListener((AdjustmentListener)(s.readObject()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
        else // skip value for unrecognized key
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
          s.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1247
     * Gets the {@code AccessibleContext} associated with this
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1248
     * {@code Scrollbar}. For scrollbars, the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1249
     * {@code AccessibleContext} takes the form of an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1250
     * {@code AccessibleAWTScrollBar}. A new
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1251
     * {@code AccessibleAWTScrollBar} instance is created if necessary.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1253
     * @return an {@code AccessibleAWTScrollBar} that serves as the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1254
     *         {@code AccessibleContext} of this {@code ScrollBar}
2
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
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
            accessibleContext = new AccessibleAWTScrollBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
     * This class implements accessibility support for the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1266
     * {@code Scrollbar} class.  It provides an implementation of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
     * the Java Accessibility API appropriate to scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
     * user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
    protected class AccessibleAWTScrollBar extends AccessibleAWTComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
        implements AccessibleValue
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
         * JDK 1.3 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
        private static final long serialVersionUID = -344337268523697807L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
         * Get the state set of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1282
         * @return an instance of {@code AccessibleState}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
         *     containing the current state of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
            if (getValueIsAdjusting()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
                states.add(AccessibleState.BUSY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
            if (getOrientation() == VERTICAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
                states.add(AccessibleState.VERTICAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
                states.add(AccessibleState.HORIZONTAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1302
         * @return an instance of {@code AccessibleRole}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
         *     describing the role of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
            return AccessibleRole.SCROLL_BAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1310
         * Get the {@code AccessibleValue} associated with this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
         * object.  In the implementation of the Java Accessibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
         * API for this class, return this object, which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
         * responsible for implementing the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1314
         * {@code AccessibleValue} interface on behalf of itself.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
         * @return this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
        public AccessibleValue getAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
         * Get the accessible value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
         * @return The current value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
        public Number getCurrentAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
            return Integer.valueOf(getValue());
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
         * Set the value of this object as a Number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
         * @return True if the value was set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
        public boolean setCurrentAccessibleValue(Number n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
            if (n instanceof Integer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
                setValue(n.intValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
         * Get the minimum accessible value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
         * @return The minimum value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
        public Number getMinimumAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
            return Integer.valueOf(getMinimum());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
         * Get the maximum accessible value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
         * @return The maximum value of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
        public Number getMaximumAccessibleValue() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
            return Integer.valueOf(getMaximum());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
    } // AccessibleAWTScrollBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
}