1 9 package bluej.editor.moe; 10 11 import java.awt.*; 12 13 import javax.swing.text.*; 14 15 import bluej.utility.Debug; 16 17 21 public class BracketMatchPainter extends DefaultHighlighter.DefaultHighlightPainter 22 { 23 24 public BracketMatchPainter(Color colour) 25 { 26 super(colour); 27 } 28 29 35 public Shape paintLayer(Graphics g, int begin, int end, Shape bounds, JTextComponent comp, View view) 36 { 37 g.setColor(getColor()); 38 Rectangle rect = null; 39 try { 40 Shape shape = view.modelToView(begin, Position.Bias.Forward, 41 end,Position.Bias.Backward, 42 bounds); 43 rect = shape.getBounds(); 44 g.drawRect(rect.x, rect.y, rect.width -1, rect.height - 1); 45 } catch (BadLocationException ble) { 46 Debug.reportError("bad location exception thrown"); 47 ble.printStackTrace(); 48 } 49 return rect; 50 } 51 52 } | Popular Tags |