JDK-4252169 : JEditorPane: The ALT attribute of the IMG tag does not work
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0,1.3.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris_2.6
  • CPU: generic,sparc
  • Submitted: 1999-07-07
  • Updated: 2000-03-09
  • Resolved: 2000-03-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
1.4.0 betaFixed
JEditorPane seems to ignore text specified using the ALT attribute of
the IMG tag.  If the image is not found, the ALT text is not displayed.

Name: krT82822			Date: 09/15/99

At <image alt=xxx> , mouse pointer is rolling over the image, the tooltip text should be shown.
But no tooltip at all.

import javax.swing.*;
import java.awt.*;

class Html03B extends JFrame {
  public static void main(String[] args) {
    Html03B frame = new Html03B( "Html03B" );
    frame.setDefaultCloseOperation(3); // EXIT_ON_CLOSE
    frame.setSize( 340, 540 );
    frame.setVisible( true );
  Html03B( String title ){
    super( title );
    Container pane = getContentPane();
    String htmlText1 = 
      "<html><body bgcolor=yellow>" +
      "<img src=file:/image/image.jpg alt=ToolTip text>" +

    JLabel htmlComponent = new JLabel( htmlText1 );
    pane.add( htmlComponent, BorderLayout.NORTH );


9/15/99 eval1127@eng -- may be dupe of 4200439
(Review ID: 95142)

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta FIXED IN: merlin-beta INTEGRATED IN: merlin-beta

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