-
Bug
-
Resolution: Unresolved
-
P3
-
7, 7u9
-
generic
-
linux, windows
FULL PRODUCT VERSION :
Ubuntu:
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
james @ /opt/java/64/jre1.7.0_09/bin
Windows:
java version " 1.7.0_10-ea "
Java(TM) SE Runtime Environment (build 1.7.0_10-ea-b09)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 10.04 : 2.6.32-44-generic #98-Ubuntu SMP Mon Sep 24 17:27:10 UTC 2012 x86_64 GNU/Linux
Windows 7 Professional SP1 x64 (under VirtualBox 3.1.6_OSE) : Version 6.1.7601
EXTRA RELEVANT SYSTEM CONFIGURATION :
Ubuntu : Using Firefox 16.01 and Chromium 18.0.1025.168 (Developer Build 134367)
Windows: Using IE9 (9.0.8112.16.4.2.1) and Firefox 16.0.1
A DESCRIPTION OF THE PROBLEM :
When using a JEditorPane to display HTML pages with images, calling setPage with a URL containing an anchor tag does not always cause the pane to scroll exactly to the position of the anchor. The location the pane scrolls to is usually in the general vicinity of the target anchor, but is sometimes displaced by several pixels in either direction.
The problem tends to be more reproducible with large HTML files and on slower machines.
It is possible that this is a regression in Java 1.7, because the problem is not reproducible on Java 1.6
No error messages appear in the Java console.
REGRESSION. Last worked in version 6u31
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
(Please see included files in source code section)
1. Compile using provided commands
2. Open embed.html in browser
3. Click " Link2 "
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Pane should scroll down such that the text " Header 2 " is at the very top of the window (anchor tag #2 is defined at this location)
ACTUAL -
Pane scrolls to a location above/below the text " Header 2 "
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
------------------------------------------------------------------------------------------------------------------
// Browser.java
------------------------------------------------------------------------------------------------------------------
import java.applet.Applet;
import java.io.IOException;
import java.net.URL;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.event.HyperlinkEvent;
public class Browser extends Applet {
private JEditorPane pane;
private JDialog dialog;
public Browser() {
pane = new JEditorPane();
pane.setContentType( " text/html " );
dialog = new JDialog();
dialog.setContentPane(new JScrollPane(pane));
try {
URL url = (URL) (Browser.class.getResource( " A.html " ));
pane.setPage(url);
} catch (IOException e) {
pane.setText( " Error while loading initial page " );
}
pane.setEditable(false);
pane.setSize(1200, 1000);
pane.addHyperlinkListener(
new javax.swing.event.HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent he) {
helpHyperlinkUpdate(he);
}
});
dialog.setSize(1200,1000);
dialog.setVisible(true);
}
private void helpHyperlinkUpdate(HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
try {
pane.setPage(event.getURL());
} catch (IOException e) {
System.out.println( " Error while loading link " );
}
}
}
}
------------------------------------------------------------------------------------------------------------------
// A.html
------------------------------------------------------------------------------------------------------------------
<html>
<body>
<p>Problem is reproducible by clicking Link2 below</p>
<a href = " B.html#1 " >Link1</a>
<a href = " B.html#2 " >Link2</a>
<a href = " B.html#3 " >Link3</a>
<a href = " B.html#4 " >Link4</a>
</body>
</html>
------------------------------------------------------------------------------------------------------------------
// B.html
------------------------------------------------------------------------------------------------------------------
<html>
<body>
<a name= " 1 " > <h2> HEADER 1 </h2></a>
<p>Lorem ipsum dolor sit amet, eos at nibh reque libris, vis recteque adolescens eu. Consul dolorum at cum, te putent quaestio adipiscing sit. Vix albucius liberavisse te. Suas voluptatibus eu pro. Primis possim in est, mei et utro
</p>
<p>
Duo ea soleat nullam blandit. Saepe saperet meliore duo ut. Est agam aeterno gloriatur eu, ponderum voluptaria cum ei. Ad labore admodum pertinax quo, invidunt ullamcorper ea has, diam agam illum te mei. Aeque efficiendi ius ei.
</p>
<p>
Ea electram vulputate his, nostrud graecis phaedrum eum in, diceret voluptaria ut vel. Vitae eirmod in mei, ius eu consul populo abhorreant. Nec in mundi concludaturque. Reprimique comprehensam mel cu. Sit ut soleat repudiare omittantur.
</p>
<img src= " http://upload.wikimedia.org/wikipedia/commons/0/01/CometNeat.jpg " />
<a name= " 2 " > <h2> HEADER 2 </h2></a>
<p>
Fugit partiendo no per, his an verear tractatos moderatius. Pro epicuri moderatius ea. Eos quod velit latine ea. Delenit dignissim ius te, quo bonorum invidunt ei.
</p>
<p>
Illud assum ad eum, eos at purto sonet salutatus. Cum veniam placerat petentium cu. Has nobis consulatu ex, ea utinam nemore vim, munere abhorreant mei et. Vim wisi eligendi assentior no, te magna dicta essent usu, cu tation tantas delic
</p>
<img src= " http://upload.wikimedia.org/wikipedia/commons/d/d5/CometBiela.jpg " />
<a name= " 3 " > <h2> HEADER 3 </h2></a>
<p>
Fugit partiendo no per, his an verear tractatos moderatius. Pro epicuri moderatius ea. Eos quod velit latine ea. Delenit dignissim ius te, quo bonorum invidunt ei.
</p>
<p>
Illud assum ad eum, eos at purto sonet salutatus. Cum veniam placerat petentium cu. Has nobis consulatu ex, ea utinam nemore vim, munere abhorreant mei et. Vim wisi eligendi assentior no, te magna dicta essent usu, cu tation tantas delic
</p>
<a name= " 4 " > <h2> HEADER 4 </h2></a>
<p>
Fugit partiendo no per, his an verear tractatos moderatius. Pro epicuri moderatius ea. Eos quod velit latine ea. Delenit dignissim ius te, quo bonorum invidunt ei.
</p>
<p>
Illud assum ad eum, eos at purto sonet salutatus. Cum veniam placerat petentium cu. Has nobis consulatu ex, ea utinam nemore vim, munere abhorreant mei et. Vim wisi eligendi assentior no, te magna dicta essent usu, cu tation tantas delic
</p>
</body>
</html>
------------------------------------------------------------------------------------------------------------------
// embed.html
------------------------------------------------------------------------------------------------------------------
<html>
<APPLET ARCHIVE= " test.jar "
CODE= " Browser.class "
WIDTH=100%
HEIGHT=100%>
</APPLET>
</html>
------------------------------------------------------------------------------------------------------------------
// (COMPILATION)
------------------------------------------------------------------------------------------------------------------
jar cf test.jar A.html B.html; javac Browser.java
Then launch a web browser pointing at embed.html and click on Link2
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround currently discovered
Ubuntu:
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
james @ /opt/java/64/jre1.7.0_09/bin
Windows:
java version " 1.7.0_10-ea "
Java(TM) SE Runtime Environment (build 1.7.0_10-ea-b09)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 10.04 : 2.6.32-44-generic #98-Ubuntu SMP Mon Sep 24 17:27:10 UTC 2012 x86_64 GNU/Linux
Windows 7 Professional SP1 x64 (under VirtualBox 3.1.6_OSE) : Version 6.1.7601
EXTRA RELEVANT SYSTEM CONFIGURATION :
Ubuntu : Using Firefox 16.01 and Chromium 18.0.1025.168 (Developer Build 134367)
Windows: Using IE9 (9.0.8112.16.4.2.1) and Firefox 16.0.1
A DESCRIPTION OF THE PROBLEM :
When using a JEditorPane to display HTML pages with images, calling setPage with a URL containing an anchor tag does not always cause the pane to scroll exactly to the position of the anchor. The location the pane scrolls to is usually in the general vicinity of the target anchor, but is sometimes displaced by several pixels in either direction.
The problem tends to be more reproducible with large HTML files and on slower machines.
It is possible that this is a regression in Java 1.7, because the problem is not reproducible on Java 1.6
No error messages appear in the Java console.
REGRESSION. Last worked in version 6u31
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
(Please see included files in source code section)
1. Compile using provided commands
2. Open embed.html in browser
3. Click " Link2 "
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Pane should scroll down such that the text " Header 2 " is at the very top of the window (anchor tag #2 is defined at this location)
ACTUAL -
Pane scrolls to a location above/below the text " Header 2 "
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
------------------------------------------------------------------------------------------------------------------
// Browser.java
------------------------------------------------------------------------------------------------------------------
import java.applet.Applet;
import java.io.IOException;
import java.net.URL;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.event.HyperlinkEvent;
public class Browser extends Applet {
private JEditorPane pane;
private JDialog dialog;
public Browser() {
pane = new JEditorPane();
pane.setContentType( " text/html " );
dialog = new JDialog();
dialog.setContentPane(new JScrollPane(pane));
try {
URL url = (URL) (Browser.class.getResource( " A.html " ));
pane.setPage(url);
} catch (IOException e) {
pane.setText( " Error while loading initial page " );
}
pane.setEditable(false);
pane.setSize(1200, 1000);
pane.addHyperlinkListener(
new javax.swing.event.HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent he) {
helpHyperlinkUpdate(he);
}
});
dialog.setSize(1200,1000);
dialog.setVisible(true);
}
private void helpHyperlinkUpdate(HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
try {
pane.setPage(event.getURL());
} catch (IOException e) {
System.out.println( " Error while loading link " );
}
}
}
}
------------------------------------------------------------------------------------------------------------------
// A.html
------------------------------------------------------------------------------------------------------------------
<html>
<body>
<p>Problem is reproducible by clicking Link2 below</p>
<a href = " B.html#1 " >Link1</a>
<a href = " B.html#2 " >Link2</a>
<a href = " B.html#3 " >Link3</a>
<a href = " B.html#4 " >Link4</a>
</body>
</html>
------------------------------------------------------------------------------------------------------------------
// B.html
------------------------------------------------------------------------------------------------------------------
<html>
<body>
<a name= " 1 " > <h2> HEADER 1 </h2></a>
<p>Lorem ipsum dolor sit amet, eos at nibh reque libris, vis recteque adolescens eu. Consul dolorum at cum, te putent quaestio adipiscing sit. Vix albucius liberavisse te. Suas voluptatibus eu pro. Primis possim in est, mei et utro
</p>
<p>
Duo ea soleat nullam blandit. Saepe saperet meliore duo ut. Est agam aeterno gloriatur eu, ponderum voluptaria cum ei. Ad labore admodum pertinax quo, invidunt ullamcorper ea has, diam agam illum te mei. Aeque efficiendi ius ei.
</p>
<p>
Ea electram vulputate his, nostrud graecis phaedrum eum in, diceret voluptaria ut vel. Vitae eirmod in mei, ius eu consul populo abhorreant. Nec in mundi concludaturque. Reprimique comprehensam mel cu. Sit ut soleat repudiare omittantur.
</p>
<img src= " http://upload.wikimedia.org/wikipedia/commons/0/01/CometNeat.jpg " />
<a name= " 2 " > <h2> HEADER 2 </h2></a>
<p>
Fugit partiendo no per, his an verear tractatos moderatius. Pro epicuri moderatius ea. Eos quod velit latine ea. Delenit dignissim ius te, quo bonorum invidunt ei.
</p>
<p>
Illud assum ad eum, eos at purto sonet salutatus. Cum veniam placerat petentium cu. Has nobis consulatu ex, ea utinam nemore vim, munere abhorreant mei et. Vim wisi eligendi assentior no, te magna dicta essent usu, cu tation tantas delic
</p>
<img src= " http://upload.wikimedia.org/wikipedia/commons/d/d5/CometBiela.jpg " />
<a name= " 3 " > <h2> HEADER 3 </h2></a>
<p>
Fugit partiendo no per, his an verear tractatos moderatius. Pro epicuri moderatius ea. Eos quod velit latine ea. Delenit dignissim ius te, quo bonorum invidunt ei.
</p>
<p>
Illud assum ad eum, eos at purto sonet salutatus. Cum veniam placerat petentium cu. Has nobis consulatu ex, ea utinam nemore vim, munere abhorreant mei et. Vim wisi eligendi assentior no, te magna dicta essent usu, cu tation tantas delic
</p>
<a name= " 4 " > <h2> HEADER 4 </h2></a>
<p>
Fugit partiendo no per, his an verear tractatos moderatius. Pro epicuri moderatius ea. Eos quod velit latine ea. Delenit dignissim ius te, quo bonorum invidunt ei.
</p>
<p>
Illud assum ad eum, eos at purto sonet salutatus. Cum veniam placerat petentium cu. Has nobis consulatu ex, ea utinam nemore vim, munere abhorreant mei et. Vim wisi eligendi assentior no, te magna dicta essent usu, cu tation tantas delic
</p>
</body>
</html>
------------------------------------------------------------------------------------------------------------------
// embed.html
------------------------------------------------------------------------------------------------------------------
<html>
<APPLET ARCHIVE= " test.jar "
CODE= " Browser.class "
WIDTH=100%
HEIGHT=100%>
</APPLET>
</html>
------------------------------------------------------------------------------------------------------------------
// (COMPILATION)
------------------------------------------------------------------------------------------------------------------
jar cf test.jar A.html B.html; javac Browser.java
Then launch a web browser pointing at embed.html and click on Link2
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround currently discovered