equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. |
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Sun designates this |
7 * published by the Free Software Foundation. Sun designates this |
35 |
35 |
36 import java.beans.PropertyChangeListener; |
36 import java.beans.PropertyChangeListener; |
37 import java.beans.PropertyChangeEvent; |
37 import java.beans.PropertyChangeEvent; |
38 |
38 |
39 import java.awt.Component; |
39 import java.awt.Component; |
40 import java.awt.Container; |
|
41 import java.awt.LayoutManager; |
|
42 import java.awt.Rectangle; |
40 import java.awt.Rectangle; |
43 import java.awt.Dimension; |
41 import java.awt.Dimension; |
44 import java.awt.Point; |
42 import java.awt.Point; |
45 import java.awt.Insets; |
43 import java.awt.Insets; |
46 import java.awt.Graphics; |
44 import java.awt.Graphics; |
47 import java.awt.event.*; |
45 import java.awt.event.*; |
48 import java.io.Serializable; |
|
49 import java.awt.Toolkit; |
|
50 import java.awt.ComponentOrientation; |
|
51 |
46 |
52 /** |
47 /** |
53 * A default L&F implementation of ScrollPaneUI. |
48 * A default L&F implementation of ScrollPaneUI. |
54 * |
49 * |
55 * @author Hans Muller |
50 * @author Hans Muller |
61 protected ChangeListener vsbChangeListener; |
56 protected ChangeListener vsbChangeListener; |
62 protected ChangeListener hsbChangeListener; |
57 protected ChangeListener hsbChangeListener; |
63 protected ChangeListener viewportChangeListener; |
58 protected ChangeListener viewportChangeListener; |
64 protected PropertyChangeListener spPropertyChangeListener; |
59 protected PropertyChangeListener spPropertyChangeListener; |
65 private MouseWheelListener mouseScrollListener; |
60 private MouseWheelListener mouseScrollListener; |
|
61 private int oldExtent = Integer.MIN_VALUE; |
66 |
62 |
67 /** |
63 /** |
68 * PropertyChangeListener installed on the vertical scrollbar. |
64 * PropertyChangeListener installed on the vertical scrollbar. |
69 */ |
65 */ |
70 private PropertyChangeListener vsbPropertyChangeListener; |
66 private PropertyChangeListener vsbPropertyChangeListener; |
325 * However, this seems a trivial bug and adding a |
321 * However, this seems a trivial bug and adding a |
326 * fix makes this often-called method slow, so I'll |
322 * fix makes this often-called method slow, so I'll |
327 * leave it until someone claims. |
323 * leave it until someone claims. |
328 */ |
324 */ |
329 value = Math.max(0, Math.min(max - extent, max - extent - viewPosition.x)); |
325 value = Math.max(0, Math.min(max - extent, max - extent - viewPosition.x)); |
|
326 if (oldExtent > extent) { |
|
327 value -= oldExtent - extent; |
|
328 } |
330 } |
329 } |
331 } |
330 } |
332 } |
331 } |
|
332 oldExtent = extent; |
333 hsb.setValues(value, extent, 0, max); |
333 hsb.setValues(value, extent, 0, max); |
334 } |
334 } |
335 |
335 |
336 if (rowHead != null) { |
336 if (rowHead != null) { |
337 Point p = rowHead.getViewPosition(); |
337 Point p = rowHead.getViewPosition(); |
1018 public void stateChanged(ChangeEvent e) { |
1018 public void stateChanged(ChangeEvent e) { |
1019 JViewport viewport = scrollpane.getViewport(); |
1019 JViewport viewport = scrollpane.getViewport(); |
1020 |
1020 |
1021 if (viewport != null) { |
1021 if (viewport != null) { |
1022 if (e.getSource() == viewport) { |
1022 if (e.getSource() == viewport) { |
1023 viewportStateChanged(e); |
1023 syncScrollPaneWithViewport(); |
1024 } |
1024 } |
1025 else { |
1025 else { |
1026 JScrollBar hsb = scrollpane.getHorizontalScrollBar(); |
1026 JScrollBar hsb = scrollpane.getHorizontalScrollBar(); |
1027 if (hsb != null && e.getSource() == hsb.getModel()) { |
1027 if (hsb != null && e.getSource() == hsb.getModel()) { |
1028 hsbStateChanged(viewport, e); |
1028 hsbStateChanged(viewport, e); |
1075 } |
1075 } |
1076 } |
1076 } |
1077 viewport.setViewPosition(p); |
1077 viewport.setViewPosition(p); |
1078 } |
1078 } |
1079 |
1079 |
1080 private void viewportStateChanged(ChangeEvent e) { |
|
1081 syncScrollPaneWithViewport(); |
|
1082 } |
|
1083 |
|
1084 |
|
1085 // |
1080 // |
1086 // PropertyChangeListener: This is installed on both the JScrollPane |
1081 // PropertyChangeListener: This is installed on both the JScrollPane |
1087 // and the horizontal/vertical scrollbars. |
1082 // and the horizontal/vertical scrollbars. |
1088 // |
1083 // |
1089 |
1084 |