KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > bluej > editor > moe > MoeEditorPane


1 // Copyright (c) 2000, 2005 BlueJ Group, Deakin University
2
//
3
// This software is made available under the terms of the "MIT License"
4
// A copy of this license is included with this source distribution
5
// in "license.txt" and is also available at:
6
// http://www.opensource.org/licenses/mit-license.html
7
// Any queries should be directed to Michael Kolling mik@bluej.org
8

9 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     /**
24      * Create an editor pane specifically for Moe.
25      */

26     public MoeEditorPane()
27     {
28         super();
29     }
30     
31     /**
32      * Adjust this pane's preferred size to add the tag area.
33      */

34     public Dimension getPreferredSize()
35     {
36         Dimension d = super.getPreferredSize();
37         d.width += BlueJSyntaxView.TAG_WIDTH + 8; // bit of empty space looks nice
38
return d;
39     }
40
41     /**
42      * Make sure, when we are scrolling to follow the caret,
43      * that we can see the tag area as well.
44      */

45     public void scrollRectToVisible(Rectangle rect)
46     {
47         super.scrollRectToVisible(new Rectangle(rect.x - (BlueJSyntaxView.TAG_WIDTH + 4), rect.y,
48                                                 rect.width + BlueJSyntaxView.TAG_WIDTH + 4, rect.height));
49     }
50 }
51
Popular Tags