1 /*
2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
358 */
359 @Override
360 protected Dimension getMinimumThumbSize() {
361 if (!validMinimumThumbSize) {
362 if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
363 minimumThumbSize.width = scrollBarWidth;
364 minimumThumbSize.height = 7;
365 } else {
366 minimumThumbSize.width = 7;
367 minimumThumbSize.height = scrollBarWidth;
368 }
369 }
370 return minimumThumbSize;
371 }
372
373 /**
374 * {@inheritDoc}
375 */
376 @Override
377 protected JButton createDecreaseButton(int orientation) {
378 SynthArrowButton synthArrowButton = new SynthArrowButton(orientation) {
379 @Override
380 public boolean contains(int x, int y) {
381 if (decrGap < 0) { //there is an overlap between the track and button
382 int width = getWidth();
383 int height = getHeight();
384 if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
385 //adjust the height by decrGap
386 //Note: decrGap is negative!
387 height += decrGap;
388 } else {
389 //adjust the width by decrGap
390 //Note: decrGap is negative!
391 width += decrGap;
392 }
393 return (x >= 0) && (x < width) && (y >= 0) && (y < height);
394 }
395 return super.contains(x, y);
396 }
397 };
398 synthArrowButton.setName("ScrollBar.button");
399 return synthArrowButton;
400 }
401
402 /**
403 * {@inheritDoc}
404 */
405 @Override
406 protected JButton createIncreaseButton(int orientation) {
407 SynthArrowButton synthArrowButton = new SynthArrowButton(orientation) {
408 @Override
409 public boolean contains(int x, int y) {
410 if (incrGap < 0) { //there is an overlap between the track and button
411 int width = getWidth();
412 int height = getHeight();
413 if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
414 //adjust the height and y by incrGap
415 //Note: incrGap is negative!
416 height += incrGap;
417 y += incrGap;
418 } else {
419 //adjust the width and x by incrGap
420 //Note: incrGap is negative!
421 width += incrGap;
422 x += incrGap;
423 }
424 return (x >= 0) && (x < width) && (y >= 0) && (y < height);
425 }
426 return super.contains(x, y);
|
1 /*
2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
358 */
359 @Override
360 protected Dimension getMinimumThumbSize() {
361 if (!validMinimumThumbSize) {
362 if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
363 minimumThumbSize.width = scrollBarWidth;
364 minimumThumbSize.height = 7;
365 } else {
366 minimumThumbSize.width = 7;
367 minimumThumbSize.height = scrollBarWidth;
368 }
369 }
370 return minimumThumbSize;
371 }
372
373 /**
374 * {@inheritDoc}
375 */
376 @Override
377 protected JButton createDecreaseButton(int orientation) {
378 @SuppressWarnings("serial") // anonymous class
379 SynthArrowButton synthArrowButton = new SynthArrowButton(orientation) {
380 @Override
381 public boolean contains(int x, int y) {
382 if (decrGap < 0) { //there is an overlap between the track and button
383 int width = getWidth();
384 int height = getHeight();
385 if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
386 //adjust the height by decrGap
387 //Note: decrGap is negative!
388 height += decrGap;
389 } else {
390 //adjust the width by decrGap
391 //Note: decrGap is negative!
392 width += decrGap;
393 }
394 return (x >= 0) && (x < width) && (y >= 0) && (y < height);
395 }
396 return super.contains(x, y);
397 }
398 };
399 synthArrowButton.setName("ScrollBar.button");
400 return synthArrowButton;
401 }
402
403 /**
404 * {@inheritDoc}
405 */
406 @Override
407 protected JButton createIncreaseButton(int orientation) {
408 @SuppressWarnings("serial") // anonymous class
409 SynthArrowButton synthArrowButton = new SynthArrowButton(orientation) {
410 @Override
411 public boolean contains(int x, int y) {
412 if (incrGap < 0) { //there is an overlap between the track and button
413 int width = getWidth();
414 int height = getHeight();
415 if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
416 //adjust the height and y by incrGap
417 //Note: incrGap is negative!
418 height += incrGap;
419 y += incrGap;
420 } else {
421 //adjust the width and x by incrGap
422 //Note: incrGap is negative!
423 width += incrGap;
424 x += incrGap;
425 }
426 return (x >= 0) && (x < width) && (y >= 0) && (y < height);
427 }
428 return super.contains(x, y);
|