EVALUATION
Yes, we currently don't support this. ImageView needs to be more sophisticated in how it handles the case of no image.
scott.violet@eng 1999-09-16
As part of 4233811 ImageView has been rewritten. It will display the alt text if the image couldn't be found, and tool tip text will be displayed on mouse over.
It was previously not possible for ImageView to show tooltip text as there was no way for a View to influence the tooltip text that will be displayed for a JTextComponent. To facilitate Views being able to effect the tooltip text a number of methods were needed. First, TextUI needed a method to get the tooltip text a particular location:
/**
* Returns the string to be used as the tooltip at the passed in location.
*
* @see javax.swing.text.JTextComponent#getToolTipText
* @since 1.4
*/
public String getToolTipText(JTextComponent t, Point pt) {
return null;
}
JTextComponents getToolTipText method then forwards to the TextUI, as long as it does not tooltip text set on it.
Second, the Views needed a way to be able to specify tooltip text:
/**
* Returns the tooltip text at the specified location. The default
* implementation returns the value from the child View identified by
* the passed in location.
*
* @since 1.4
* @see JTextComponent#getToolTipText
*/
public String getToolTipText(float x, float y, Shape allocation)
The default implementation of View.getToolTipText will forward the method to the Views child at the given location. To make it easy to determine the child at a particular location, the following method was added:
/**
* Returns the child view index representing the given position in
* the view. This iterates over all the children returning the
* first with a bounds that contains <code>x</code>, <code>y</code>.
*
* @param x the x coordinate
* @param y the y coordinate
* @param allocation current allocation of the View.
* @return index of the view representing the given location, or
* -1 if no view represents that position
* @since 1.4
*/
public int getViewIndex(float x, float y, Shape allocation) {
Views implementation invokes getViewIndex and then getToolTipText on the child View. ImageView then overrides getToolTipText and returns the value from the ALT attribute of its AttributeSet.
###@###.### 2000-02-28
In order for JEditorPane to have tooltips, you need to register it with
the ToolTipManager. For example:
ToolTipManager.sharedInstance().registerComponent(p);
This is indicated in the javadoc for JTextComponent:
* By defaulToolTipManager.sharedInstance().registerComponent(p);
* itself with the <code>ToolTipManager</code>.
* This means that tooltips will NOT be shown from the
* <code>TextUI</code> unless <code>registerComponent</code> has
* been invoked on the <code>ToolTipManager</code>.
###@###.### 2002-02-15
|