by Bob Futrelle, January 2003 This demo shows how a large panel of text can be scrolled in a Swing JScrollPane. Scroll down for line #49. The panel the text is drawn on is 1000 pixels tall, taller than any normal screen. The major extensions of this we'll need for the NLP work will be to carefully position the text to align certain words as well as allowing mouse selection of lines or words. I tried using a 10,000 pixel tall window too, with 500 lines and it works just fine. That's about 10000/72 = 140" tall, 11-1/2 feet tall, or 15 pages worth. It runs smoothly, with no problems at all. So I tried a version 10x this size, 100+ feet tall, 150 pages worth, 5000 lines. It's a tiny bit sluggish on my PowerBook, but hardly noticable. It's clear that we've got all the power we need here. To run this, do: java MyScroll that creates a Scroller and executes its run() command. Scroller is a top level JFrame that creates a tall(!) JPanel for the text, inserts it in a JScrollPane and adds the scroll pane to the JFrame. Some points I had to pay attention to to get things to work properly: 1. (most important) I used setPreferredSize() for both the JPanel and the JScrollPane. For the top-level JFrame, I simply use setSize(). 2. The JPanel I used is called TextPanel, which subclasses JPanel and defines a paintComponent(Graphics g) method, not a paint() method that you'll ordinarily see used and as its first instruction, calls super.paintComponent(g). paintComponent is more robust than paint() and is now the recommended method to use. If you want to see a scrolling list with radio button selections, run ScrollDemo or ScrollDemo2 in the jswing2BookMisc/ directory. They're taken from Java Swing, 2nd edition by Loy, et al, (O'Reilly, 2003) -- there's a copy in the lab.