01: // Copyright (c) 2000, 2005 BlueJ Group, Deakin University
02: //
03: // This software is made available under the terms of the "MIT License"
04: // A copy of this license is included with this source distribution
05: // in "license.txt" and is also available at:
06: // http://www.opensource.org/licenses/mit-license.html
07: // Any queries should be directed to Michael Kolling mik@bluej.org
08:
09: package bluej.editor.moe;
10:
11: import java.awt.*;
12: import javax.swing.*;
13:
14: /**
15: * MoeJEditorPane - a variation of JEditorPane for Moe. The preferred size
16: * is adjusted to allow for the tag line.
17: *
18: * @author Michael Kolling
19: */
20:
21: public final class MoeEditorPane extends JEditorPane {
22: /**
23: * Create an editor pane specifically for Moe.
24: */
25: public MoeEditorPane() {
26: super ();
27: }
28:
29: /**
30: * Adjust this pane's preferred size to add the tag area.
31: */
32: public Dimension getPreferredSize() {
33: Dimension d = super .getPreferredSize();
34: d.width += BlueJSyntaxView.TAG_WIDTH + 8; // bit of empty space looks nice
35: return d;
36: }
37:
38: /**
39: * Make sure, when we are scrolling to follow the caret,
40: * that we can see the tag area as well.
41: */
42: public void scrollRectToVisible(Rectangle rect) {
43: super .scrollRectToVisible(new Rectangle(rect.x
44: - (BlueJSyntaxView.TAG_WIDTH + 4), rect.y, rect.width
45: + BlueJSyntaxView.TAG_WIDTH + 4, rect.height));
46: }
47: }
|