格式化JEditorPane的光标,工具提示,链接 [英] Formatting JEditorPane's cursor, tooltips, links

查看:105
本文介绍了格式化JEditorPane的光标,工具提示,链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我正在使用Java Swing创建一个JEditorPane,主要是因为它具有超链接的能力。我已成功地显示链接并让它们在单击时执行行为,但我遇到了一些格式问题。

Right now, I'm using Java Swing to create a JEditorPane primarily for its ability to have hyperlinks. I've successfully been able to display links and have them execute behavior upon a click, but I'm running into a few problems with formatting.


  1. 如何设置光标以使其通常为箭头,但是当将鼠标悬停在文本上时会更改为文本光标? (实质上,光标在Web浏览器中的行为)。我试过

  1. How can I set the cursor so that it normally is an arrow, but changes to a text cursor when hovering over text? (In essence, the behavior a cursor has within a web browser). I tried

EditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR))

但这使得它成为一个文本光标,即使没有悬停在文本上也是如此。现在,悬停在一个链接上显示一个指针;我也想维护这个功能。

but that made it a text cursor everywhere, even when not hovering over text. Right now, hovering over a link shows a pointer hand; I'd like to maintain that functionality as well.

将鼠标悬停在链接上时,显示工具提示或鼠标悬停文本的最佳方法是什么?我尝试修改链接的title属性但没有显示任何内容。

What is the best way to show tooltips or mouseover text when hovering over a link? I tried modifying the title attribute of the link but nothing showed up.

我试图实现链接以跳到页面的子部分,非常像 http://en.wikipedia.org/wiki/Xkcd#History 会直接带您维基百科的xkcd页面的历史子部分。我怎么能这样做?

I was trying to implement links to skip down to a subsection of the page, much like http://en.wikipedia.org/wiki/Xkcd#History would take you directly to the History subsection of Wikipedia's xkcd page. How can I do this?

对这些中的任何一个的回答都会很棒(多个会很棒xP) 。非常感谢你的帮助!

An answer to any of these would be great (and multiple would be awesome xP). Thanks a lot for your help!

推荐答案

正如你所说的那样,我也可以简单地给出单点的答案,让我试一试一个接一个,这里是你上一个第3点的答案

As you said one can simply give answers to a single point as well, let me try one by one, here is the answer for your last Point 3

只需为你的标签提供一个id

Just provide an id to your tag like this

<h1><a id = "top"></a>First Line</h1>

现在位于页面底部的某处写下:

Now somewhere in the bottom of your page write this :

<p><a href = "#top">Return to TOP</a></p>

点击此链接,您将到达PAGE的上述区域。

Clicking this link, you will reach the above area of the PAGE.

这篇关于格式化JEditorPane的光标,工具提示,链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆