Last change
on this file since 25584 was 25584, checked in by davidb, 12 years ago |
Initial cut an a text edit area for GLI that supports color syntax highlighting
|
File size:
1.4 KB
|
Line | |
---|
1 | /*
|
---|
2 | * 07/23/2009
|
---|
3 | *
|
---|
4 | * ChangeableColorHighlightPainter.java - A highlighter whose color you can
|
---|
5 | * change.
|
---|
6 | *
|
---|
7 | * This library is distributed under a modified BSD license. See the included
|
---|
8 | * RSyntaxTextArea.License.txt file for details.
|
---|
9 | */
|
---|
10 | package org.fife.ui.rsyntaxtextarea;
|
---|
11 |
|
---|
12 | import java.awt.Color;
|
---|
13 | import javax.swing.text.DefaultHighlighter.DefaultHighlightPainter;
|
---|
14 |
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * A highlighter whose color you can change.
|
---|
18 | *
|
---|
19 | * @author Robert Futrell
|
---|
20 | * @version 1.0
|
---|
21 | */
|
---|
22 | class ChangeableColorHighlightPainter extends DefaultHighlightPainter {
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * DefaultHighlightPainter doesn't allow changing color, so we must cache
|
---|
26 | * ours here.
|
---|
27 | */
|
---|
28 | private Color color;
|
---|
29 |
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * Constructor.
|
---|
33 | *
|
---|
34 | * @param color The initial color to use. This cannot be <code>null</code>.
|
---|
35 | */
|
---|
36 | public ChangeableColorHighlightPainter(Color color) {
|
---|
37 | super(color);
|
---|
38 | setColor(color);
|
---|
39 | }
|
---|
40 |
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Returns the color to paint with.
|
---|
44 | *
|
---|
45 | * @return The color.
|
---|
46 | * @see #setColor(Color)
|
---|
47 | */
|
---|
48 | public Color getColor() {
|
---|
49 | return color;
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Sets the color to paint the bounding boxes with.
|
---|
55 | *
|
---|
56 | * @param color The new color. This cannot be <code>null</code>.
|
---|
57 | * @see #getColor()
|
---|
58 | */
|
---|
59 | public void setColor(Color color) {
|
---|
60 | if (color==null) {
|
---|
61 | throw new IllegalArgumentException("color cannot be null");
|
---|
62 | }
|
---|
63 | this.color = color;
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.