[jsword-devel] Improved CSS
Joe Walker
jsword-devel@crosswire.org
Sun, 21 Mar 2004 00:43:42 +0000
Excellent - good one, I tried to do that just using CSS but failed.
Thanks,
Joe.
DM Smith wrote:
> I have made changes to Desktop.java (HyperlinkListener) and
> cswing/simple.xsl such that when you enter a link it is underlined and
> shows the hand cursor. When you leave, it reverts to what it was before.
>
> I have tried to get a current copy of what is in CVS before I created
> the patches, but some new directories have permission problems. As a
> result, I have not fully tested the code. I can wait till tomorrow for
> the nightly build to reset the permissions. Then I can finalize the
> test against the new code.
>
> The core of the idea is that in the HTML links are not underlined. In
> the HyperlinkListener, it looks for enter to underline and leave to
> remove the underline.
>
> Turns out the code change is small. I first had to verify that all
> uses of JEditorPane were actually JTextPane, as it relies on the
> widget being JTextPane with all of its abilities to set styles.
>
> The code is essentially the following:
> if (ev is enter or exit)
> {
> // Must be either an enter or an exit event
> // simulate a link rollover effect
> // (a CSS style not supported in 1.4)
> Element textElement = ev.getSourceElement();
> // Focus is needed to decorate Enter and Leave events
> pane.grabFocus();
> int start = textElement.getStartOffset();
> int length = textElement.getEndOffset() - start;
> Style style = pane.addStyle("HyperLink", null);
> StyleConstants.setUnderline(style, type ==
> HyperlinkEvent.EventType.ENTERED);
> StyledDocument doc = pane.getStyledDocument();
> doc.setCharacterAttributes(start, length, style, false);
> }
>
> Attached is a zip with two patches, one for each file. And it also
> contains the java files.
>
> _________________________________________________________________
> Is your PC infected? Get a FREE online computer virus scan from
> McAfee. Security.
> http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963