1 package org.columba.core.gui.search; 19 20 import java.awt.Dimension ; 21 import java.awt.Rectangle ; 22 23 import javax.swing.JComponent ; 24 import javax.swing.JPanel ; 25 import javax.swing.JViewport ; 26 import javax.swing.Scrollable ; 27 28 import org.jdesktop.swingx.VerticalLayout; 29 30 36 public class StackedBox extends JPanel implements Scrollable { 37 38 41 private static final long serialVersionUID = 6499186046747795448L; 42 43 44 47 public StackedBox() { 48 setLayout(new VerticalLayout()); 49 setOpaque(true); 50 51 } 52 53 54 59 public void addBox(JComponent box) { 60 add(box); 61 } 62 63 66 public Dimension getPreferredScrollableViewportSize() { 67 return getPreferredSize(); 68 } 69 70 73 public int getScrollableBlockIncrement(Rectangle visibleRect, 74 int orientation, int direction) { 75 return 10; 76 } 77 78 81 public boolean getScrollableTracksViewportHeight() { 82 if (getParent() instanceof JViewport ) { 83 return (((JViewport ) getParent()).getHeight() > getPreferredSize().height); 84 } else { 85 return false; 86 } 87 } 88 89 92 public boolean getScrollableTracksViewportWidth() { 93 return true; 94 } 95 96 99 public int getScrollableUnitIncrement(Rectangle visibleRect, 100 int orientation, int direction) { 101 return 10; 102 } 103 } 104 | Popular Tags |