import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.border.*;
import javax.swing.colorchooser.*;
import javax.swing.filechooser.*;
import javax.accessibility.*;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.util.*;
import java.io.*;
import java.applet.*;
import java.net.*;
public class ImageScroller extends JScrollPane {
public ImageScroller(Component component) {
super(component);
// Create and add a column header to the scrollpane
JLabel colHeader = new JLabel(
createImageIcon("scrollpane/colheader.jpg" ));
setColumnHeaderView(colHeader);
// Create and add a row header to the scrollpane
JLabel rowHeader = new JLabel(
createImageIcon("scrollpane/rowheader.jpg" ));
setRowHeaderView(rowHeader);
// Create and add the upper left corner
JLabel cornerUL = new JLabel(
createImageIcon("scrollpane/upperleft.jpg" ));
setCorner(UPPER_LEFT_CORNER, cornerUL);
// Create and add the upper right corner
JLabel cornerUR = new JLabel(
createImageIcon("scrollpane/upperright.jpg" ));
setCorner(UPPER_RIGHT_CORNER, cornerUR);
// Create and add the lower left corner
JLabel cornerLL = new JLabel(
createImageIcon("scrollpane/lowerleft.jpg" ));
setCorner(LOWER_LEFT_CORNER, cornerLL);
JScrollBar vsb = getVerticalScrollBar();
JScrollBar hsb = getHorizontalScrollBar();
// vsb.setValue(icon.getIconHeight());
// hsb.setValue(icon.getIconWidth()/10);
}
public ImageIcon createImageIcon(String filename) {
String path = "/images/" + filename;
return new ImageIcon(getClass().getResource(path)); }
public static void main(String args[])
{
JFrame d = new JFrame("Hello" );
d.getContentPane().add(new ImageScroller(new JTextArea()));
d.setDefaultCloseOperation(3);
d.setSize(500,500);
d.setVisible(true);
}
}
|