1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.widgets;
|
---|
3 |
|
---|
4 | import java.awt.Dimension;
|
---|
5 | import java.awt.LayoutManager;
|
---|
6 | import java.awt.Rectangle;
|
---|
7 |
|
---|
8 | import javax.swing.JPanel;
|
---|
9 | import javax.swing.JScrollPane;
|
---|
10 | import javax.swing.Scrollable;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.gui.util.GuiHelper;
|
---|
13 |
|
---|
14 | public class VerticallyScrollablePanel extends JPanel implements Scrollable {
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Constructs a new {@code VerticallyScrollablePanel}.
|
---|
18 | */
|
---|
19 | public VerticallyScrollablePanel() {
|
---|
20 | super();
|
---|
21 | }
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Constructs a new {@code VerticallyScrollablePanel}.
|
---|
25 | * @param isDoubleBuffered a boolean, true for double-buffering, which
|
---|
26 | * uses additional memory space to achieve fast, flicker-free updates
|
---|
27 | */
|
---|
28 | public VerticallyScrollablePanel(boolean isDoubleBuffered) {
|
---|
29 | super(isDoubleBuffered);
|
---|
30 | }
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Constructs a new {@code VerticallyScrollablePanel}.
|
---|
34 | * @param layout the LayoutManager to use
|
---|
35 | * @param isDoubleBuffered a boolean, true for double-buffering, which
|
---|
36 | * uses additional memory space to achieve fast, flicker-free updates
|
---|
37 | */
|
---|
38 | public VerticallyScrollablePanel(LayoutManager layout, boolean isDoubleBuffered) {
|
---|
39 | super(layout, isDoubleBuffered);
|
---|
40 | }
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Constructs a new {@code VerticallyScrollablePanel}.
|
---|
44 | * @param layout the LayoutManager to use
|
---|
45 | */
|
---|
46 | public VerticallyScrollablePanel(LayoutManager layout) {
|
---|
47 | super(layout);
|
---|
48 | }
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Returns a vertical scrollable {@code JScrollPane} containing this panel.
|
---|
52 | * @return the vertical scrollable {@code JScrollPane}
|
---|
53 | * @since 6666
|
---|
54 | */
|
---|
55 | public final JScrollPane getVerticalScrollPane() {
|
---|
56 | return GuiHelper.embedInVerticalScrollPane(this);
|
---|
57 | }
|
---|
58 |
|
---|
59 | @Override
|
---|
60 | public Dimension getPreferredScrollableViewportSize() {
|
---|
61 | return getPreferredSize();
|
---|
62 | }
|
---|
63 |
|
---|
64 | @Override
|
---|
65 | public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
|
---|
66 | return 20;
|
---|
67 | }
|
---|
68 |
|
---|
69 | @Override
|
---|
70 | public boolean getScrollableTracksViewportHeight() {
|
---|
71 | return false;
|
---|
72 | }
|
---|
73 |
|
---|
74 | @Override
|
---|
75 | public boolean getScrollableTracksViewportWidth() {
|
---|
76 | return true;
|
---|
77 | }
|
---|
78 |
|
---|
79 | @Override
|
---|
80 | public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
|
---|
81 | return 10;
|
---|
82 | }
|
---|
83 | }
|
---|