1 36 37 40 41 42 import javax.swing.*; 43 import javax.swing.event.*; 44 import javax.swing.text.*; 45 import javax.swing.border.*; 46 import javax.swing.colorchooser.*; 47 import javax.swing.filechooser.*; 48 import javax.accessibility.*; 49 50 import java.awt.*; 51 import java.awt.event.*; 52 import java.beans.*; 53 import java.util.*; 54 import java.io.*; 55 import java.applet.*; 56 import java.net.*; 57 58 64 public class ScrollPaneDemo extends DemoModule { 65 66 69 public static void main(String [] args) { 70 ScrollPaneDemo demo = new ScrollPaneDemo(null); 71 demo.mainImpl(); 72 } 73 74 77 public ScrollPaneDemo(SwingSet2 swingset) { 78 super(swingset, "ScrollPaneDemo", "toolbar/JScrollPane.gif"); 79 80 ImageIcon crayons = createImageIcon("scrollpane/crayons.jpg", getString("ScrollPaneDemo.crayons")); 81 getDemoPanel().add(new ImageScroller(this, crayons), BorderLayout.CENTER); 82 } 83 84 85 89 class ImageScroller extends JScrollPane { 90 public ImageScroller(ScrollPaneDemo demo, Icon icon) { 91 super(); 92 93 JPanel p = new JPanel(new BorderLayout()); 95 p.add(new JLabel(icon), BorderLayout.CENTER); 96 getViewport().add(p); 97 98 JLabel colHeader = new JLabel( 100 demo.createImageIcon("scrollpane/colheader.jpg", getString("ScrollPaneDemo.colheader"))); 101 setColumnHeaderView(colHeader); 102 103 JLabel rowHeader = new JLabel( 105 demo.createImageIcon("scrollpane/rowheader.jpg", getString("ScrollPaneDemo.rowheader"))); 106 setRowHeaderView(rowHeader); 107 108 JLabel cornerUL = new JLabel( 110 demo.createImageIcon("scrollpane/upperleft.jpg", getString("ScrollPaneDemo.upperleft"))); 111 setCorner(UPPER_LEFT_CORNER, cornerUL); 112 113 JLabel cornerUR = new JLabel( 115 demo.createImageIcon("scrollpane/upperright.jpg", getString("ScrollPaneDemo.upperright"))); 116 setCorner(UPPER_RIGHT_CORNER, cornerUR); 117 118 JLabel cornerLL = new JLabel( 120 demo.createImageIcon("scrollpane/lowerleft.jpg", getString("ScrollPaneDemo.lowerleft"))); 121 setCorner(LOWER_LEFT_CORNER, cornerLL); 122 123 JScrollBar vsb = getVerticalScrollBar(); 124 JScrollBar hsb = getHorizontalScrollBar(); 125 126 vsb.setValue(icon.getIconHeight()); 127 hsb.setValue(icon.getIconWidth()/10); 128 } 129 } 130 131 } 132 133 | Popular Tags |