1 /*
2 * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
279 private static final long serialVersionUID = 8451667562882310543L;
280
281 /**
282 * Initialize JNI field and method IDs.
283 */
284 private static native void initIDs();
285
286 static {
287 /* ensure that the necessary native libraries are loaded */
288 Toolkit.loadLibraries();
289 if (!GraphicsEnvironment.isHeadless()) {
290 initIDs();
291 }
292 }
293
294 /**
295 * Constructs a new vertical scroll bar.
296 * The default properties of the scroll bar are listed in
297 * the following table:
298 *
299 * <table border=1 summary="Scrollbar default properties">
300 * <tr>
301 * <th>Property</th>
302 * <th>Description</th>
303 * <th>Default Value</th>
304 * </tr>
305 * <tr>
306 * <td>orientation</td>
307 * <td>indicates whether the scroll bar is vertical
308 * <br>or horizontal</td>
309 * <td>{@code Scrollbar.VERTICAL}</td>
310 * </tr>
311 * <tr>
312 * <td>value</td>
313 * <td>value which controls the location
314 * <br>of the scroll bar's bubble</td>
315 * <td>0</td>
316 * </tr>
317 * <tr>
318 * <td>visible amount</td>
319 * <td>visible amount of the scroll bar's range,
320 * <br>typically represented by the size of the
321 * <br>scroll bar's bubble</td>
322 * <td>10</td>
323 * </tr>
324 * <tr>
330 * <td>maximum</td>
331 * <td>maximum value of the scroll bar</td>
332 * <td>100</td>
333 * </tr>
334 * <tr>
335 * <td>unit increment</td>
336 * <td>amount the value changes when the
337 * <br>Line Up or Line Down key is pressed,
338 * <br>or when the end arrows of the scrollbar
339 * <br>are clicked </td>
340 * <td>1</td>
341 * </tr>
342 * <tr>
343 * <td>block increment</td>
344 * <td>amount the value changes when the
345 * <br>Page Up or Page Down key is pressed,
346 * <br>or when the scrollbar track is clicked
347 * <br>on either side of the bubble </td>
348 * <td>10</td>
349 * </tr>
350 * </table>
351 *
352 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
353 * returns true.
354 * @see java.awt.GraphicsEnvironment#isHeadless
355 */
356 public Scrollbar() throws HeadlessException {
357 this(VERTICAL, 0, 10, 0, 100);
358 }
359
360 /**
361 * Constructs a new scroll bar with the specified orientation.
362 * <p>
363 * The {@code orientation} argument must take one of the two
364 * values {@code Scrollbar.HORIZONTAL},
365 * or {@code Scrollbar.VERTICAL},
366 * indicating a horizontal or vertical scroll bar, respectively.
367 *
368 * @param orientation indicates the orientation of the scroll bar
369 * @exception IllegalArgumentException when an illegal value for
|
1 /*
2 * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
279 private static final long serialVersionUID = 8451667562882310543L;
280
281 /**
282 * Initialize JNI field and method IDs.
283 */
284 private static native void initIDs();
285
286 static {
287 /* ensure that the necessary native libraries are loaded */
288 Toolkit.loadLibraries();
289 if (!GraphicsEnvironment.isHeadless()) {
290 initIDs();
291 }
292 }
293
294 /**
295 * Constructs a new vertical scroll bar.
296 * The default properties of the scroll bar are listed in
297 * the following table:
298 *
299 * <table class="striped">
300 * <caption>Scrollbar default properties</caption>
301 * <thead>
302 * <tr>
303 * <th>Property</th>
304 * <th>Description</th>
305 * <th>Default Value</th>
306 * </tr>
307 * </thead>
308 * <tbody>
309 * <tr>
310 * <td>orientation</td>
311 * <td>indicates whether the scroll bar is vertical
312 * <br>or horizontal</td>
313 * <td>{@code Scrollbar.VERTICAL}</td>
314 * </tr>
315 * <tr>
316 * <td>value</td>
317 * <td>value which controls the location
318 * <br>of the scroll bar's bubble</td>
319 * <td>0</td>
320 * </tr>
321 * <tr>
322 * <td>visible amount</td>
323 * <td>visible amount of the scroll bar's range,
324 * <br>typically represented by the size of the
325 * <br>scroll bar's bubble</td>
326 * <td>10</td>
327 * </tr>
328 * <tr>
334 * <td>maximum</td>
335 * <td>maximum value of the scroll bar</td>
336 * <td>100</td>
337 * </tr>
338 * <tr>
339 * <td>unit increment</td>
340 * <td>amount the value changes when the
341 * <br>Line Up or Line Down key is pressed,
342 * <br>or when the end arrows of the scrollbar
343 * <br>are clicked </td>
344 * <td>1</td>
345 * </tr>
346 * <tr>
347 * <td>block increment</td>
348 * <td>amount the value changes when the
349 * <br>Page Up or Page Down key is pressed,
350 * <br>or when the scrollbar track is clicked
351 * <br>on either side of the bubble </td>
352 * <td>10</td>
353 * </tr>
354 * </tbody>
355 * </table>
356 *
357 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
358 * returns true.
359 * @see java.awt.GraphicsEnvironment#isHeadless
360 */
361 public Scrollbar() throws HeadlessException {
362 this(VERTICAL, 0, 10, 0, 100);
363 }
364
365 /**
366 * Constructs a new scroll bar with the specified orientation.
367 * <p>
368 * The {@code orientation} argument must take one of the two
369 * values {@code Scrollbar.HORIZONTAL},
370 * or {@code Scrollbar.VERTICAL},
371 * indicating a horizontal or vertical scroll bar, respectively.
372 *
373 * @param orientation indicates the orientation of the scroll bar
374 * @exception IllegalArgumentException when an illegal value for
|