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 | public class VerticallyScrollablePanel extends JPanel implements Scrollable {
|
---|
13 |
|
---|
14 | static public JScrollPane embed(VerticallyScrollablePanel panel) {
|
---|
15 | JScrollPane sp = new JScrollPane(panel);
|
---|
16 | sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
---|
17 | sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
---|
18 | return sp;
|
---|
19 | }
|
---|
20 |
|
---|
21 | public VerticallyScrollablePanel() {
|
---|
22 | super();
|
---|
23 | }
|
---|
24 |
|
---|
25 | public VerticallyScrollablePanel(boolean isDoubleBuffered) {
|
---|
26 | super(isDoubleBuffered);
|
---|
27 | }
|
---|
28 |
|
---|
29 | public VerticallyScrollablePanel(LayoutManager layout, boolean isDoubleBuffered) {
|
---|
30 | super(layout, isDoubleBuffered);
|
---|
31 | }
|
---|
32 |
|
---|
33 | public VerticallyScrollablePanel(LayoutManager layout) {
|
---|
34 | super(layout);
|
---|
35 | }
|
---|
36 |
|
---|
37 | public Dimension getPreferredScrollableViewportSize() {
|
---|
38 | return getPreferredSize();
|
---|
39 | }
|
---|
40 |
|
---|
41 | public int getScrollableBlockIncrement(Rectangle arg0, int arg1, int arg2) {
|
---|
42 | return 20;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public boolean getScrollableTracksViewportHeight() {
|
---|
46 | return false;
|
---|
47 | }
|
---|
48 |
|
---|
49 | public boolean getScrollableTracksViewportWidth() {
|
---|
50 | return true;
|
---|
51 | }
|
---|
52 |
|
---|
53 | public int getScrollableUnitIncrement(Rectangle arg0, int arg1, int arg2) {
|
---|
54 | return 10;
|
---|
55 | }
|
---|
56 | }
|
---|