United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4712089 : REGRESSION 1.4.0: Focus moves incorrectly on JEditorPane using HTMLEditor Kit an

Details
Type:
Bug
Submit Date:
2002-07-09
Status:
Resolved
Updated Date:
2002-09-28
Project Name:
JDK
Resolved Date:
2002-09-28
Component:
client-libs
OS:
linux,generic
Sub-Component:
javax.swing
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0,1.4.1
Fixed Versions:
1.4.2 (mantis)

Related Reports
Duplicate:

Sub Tasks

Description

Name: dk106046			Date: 07/09/2002

java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b16)
Java HotSpot(TM) Client VM (build 1.4.1-rc-b16, mixed mode)

Steps to reproduce:

1) Compile the JEditorPaneTest.java listed below.
2) Prepare the test.html listed below
3) run "java JEditorPaneTest test.html"
4) Once the JEditorPaneTest is up, you should see a Input field and TextArea field, generated by html form.
5) Click the Input field (first one)
6) Type any character - you should notice that the focus jump to the TextArea instead of stay with TextArea <---------- PROBLEM!

-------------- Sample code: JEditorPaneTest.java -------------------
/*
 * JEditorPaneTest.java
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;

public class JEditorPaneTest extends JFrame {
       Component c;
       public JEditorPaneTest(String filename) {
              super("JEditorPane Test");
              String str = readHTMLFile(filename);

              try{
                     JEditorPane jep = new JEditorPane("text/html", str);
                      jep.setEditable(false);
                     this.getContentPane().setLayout(new BorderLayout());
                     this.getContentPane().add(new JScrollPane(jep), BorderLayout.CENTER);
              }catch(Exception e){
                     e.printStackTrace();
              }
              addWindowListener(new WindowAdapter() {
                     public void windowClosing(WindowEvent event) {
                            System.exit(0);
                     }
              });
              setSize(400, 400);
              show();
       }
       protected String readHTMLFile(String filename){
              BufferedReader reader = null;
              StringBuffer buff = new StringBuffer();
              try{
                     reader = new BufferedReader(new FileReader(filename));
                     while (reader.ready()){
                            buff.append(reader.readLine() + "\n");
                     }
              }catch(Exception e){
                     e.printStackTrace();
              }finally{
                     if (reader != null){
                            try{ reader.close(); }catch(Exception e){ e.printStackTrace(); }
                     }
              }
              return buff.toString();
       }
       public static void main(String[] args) {
              new JEditorPaneTest(args[0]);
       }
}

--------------------------------------------------------------------

------------------ Sample File: test.html --------------------------
<html>
<body>
<form>
Input: <input name="text1" value="hello" size="80">
<p>
TextArea: <textarea name="text2" rows="10" cols="80">hello world</textarea>
</form>
</body>
</html>
--------------------------------------------------------------------

======================================================================

                                    

Comments
SUGGESTED FIX

see http://sa.sfbay.sun.com/swing/mantis/4712089/ for the details
###@###.### 2002-09-17
                                     
2002-09-17
EVALUATION

The problem is with FlowLayout.FlowStrategy.adjustRow

it does r.replace. when it happens for componentView the focus moves to the
next component. 
###@###.### 2002-09-17
                                     
2002-09-17
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
generic
mantis

FIXED IN:
mantis

INTEGRATED IN:
mantis
mantis-b03


                                     
2004-06-14



Hardware and Software, Engineered to Work Together