作为标题,我将如何在对象上放置提示或描述,以便如果用户将鼠标悬停在方法或对象上,他们将获得类似于具有解释的标准对象库的描述。我到处搜索,但找不到示例。
问问题
1115 次
2 回答
6
您需要使用 JavaDoc 注释,例如:
/**
* This method returns the x value.
*
* @return the x value
*/
public int getValue()
{
return x;
}
有关这方面的更多信息,请参阅:如何为 Javadoc 工具编写文档注释
于 2012-07-31T09:05:28.357 回答
3
这可以通过使用 JavaDoc 来实现。
http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
上页示例:
/**
* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute {@link URL}. The name
* argument is a specifier that is relative to the url argument.
* <p>
* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
*
* @param url an absolute URL giving the base location of the image
* @param name the location of the image, relative to the url argument
* @return the image at the specified URL
* @see Image
*/
public Image getImage(URL url, String name) {
try {
return getImage(new URL(url, name));
} catch (MalformedURLException e) {
return null;
}
}
此外,您还需要一个支持此功能的 IDE,例如 Eclipse。
于 2012-07-31T09:05:35.167 回答