add highlight in pure programmatically
Peter Cheung <[email protected]> Sun, 17 Sep 2017 16:52:02 +0000
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <ME1PR01MB02602D25BE75D99C620464CCB5620@ME1PR01MB0260.ausprd01.prod.outlook.com> |
--_000_ME1PR01MB02602D25BE75D99C620464CCB5620ME1PR01MB0260ausp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi
Why the following code has no effect to add highlight?
EditorCookie ec =3D dataObject.getLookup().lookup(EditorCookie.class);
Document doc2 =3D ec.getDocument();
OffsetsBag bag =3D new OffsetsBag(doc2, true);
AttributeSet defaultColors =3D AttributesUtilities.createImmutable(StyleCon=
stants.Background, new Color(0, 0, 255));
bag.addHighlight(5, 10, defaultColors);
AttributeSet defaultColors2 =3D AttributesUtilities.createImmutable(StyleCo=
nstants.Foreground, new Color(0, 255, 255));
bag.addHighlight(2, 5, defaultColors2);
Thanks
From Peter
--_000_ME1PR01MB02602D25BE75D99C620464CCB5620ME1PR01MB0260ausp_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"><!-- P {margin-top:0;margi=
n-bottom:0;} --></style>
</head>
<body dir=3D"ltr">
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
color: rgb(0, 0, 0);">
Hi</div>
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
color: rgb(0, 0, 0);">
Why the following code has no effect to add highlight?</div>
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
color: rgb(0, 0, 0);">
<br>
</div>
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
color: rgb(0, 0, 0);">
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"></span>Editor=
Cookie ec =3D dataObject.getLookup().lookup(EditorCookie.class);</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"></span>Docume=
nt doc2 =3D ec.getDocument();</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"></span>Offset=
sBag bag =3D new OffsetsBag(doc2, true);</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"></span>Attrib=
uteSet defaultColors =3D AttributesUtilities.createImmutable(StyleConstants=
.Background, new Color(0, 0, 255));</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"></span>bag.ad=
dHighlight(5, 10, defaultColors);</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"></span>Attrib=
uteSet defaultColors2 =3D AttributesUtilities.createImmutable(StyleConstant=
s.Foreground, new Color(0, 255, 255));</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"></span>bag.ad=
dHighlight(2, 5, defaultColors2);</div>
<br>
</div>
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
color: rgb(0, 0, 0);">
Thanks</div>
<div style=3D"font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;=
color: rgb(0, 0, 0);">
From Peter</div>
</body>
</html>
--_000_ME1PR01MB02602D25BE75D99C620464CCB5620ME1PR01MB0260ausp_--