JDK-4225456 : JSplitPane causes focus lost events to cease after Solaris window is resized
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 1999-03-31
  • Updated: 2001-01-05
  • Resolved: 2001-01-05
Related Reports
Duplicate :  
Description

Name: dbT83986			Date: 03/30/99


Below is the demo program. See the comment at the top for 
everything you need to reproduce this one.

/*

This bug only happens on Solaris. It happens in both 
JDK 1.2 and Swing 1.0.2.

With useJSplitPane set to true, see the bug as follows:

  1. click in textfield and type
  2. change X focus to another window (note focusLost)
  3. click in textfield and type again
  4. resize the window
  5. click in textfield and type again
  6. change X focus to another window (bug is no focusLost
     and you never can get focusLost on the textfield again)

Set useJSplitPane to false and repeat the steps. This uses a Jpanel
instead of a JSplitPane. This has no problem. It gives focusLost
forever as it should.


To compile and run:

> javac JSplitPaneFocusBug.java
> java JSplitPaneFocusBug

*/


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

public class JSplitPaneFocusBug extends JFrame {
  public JSplitPaneFocusBug() { 
    boolean      useJSplitPane = true; // cut and paste these: true or false

    JTextField tf = new JTextField();
    tf.setEditable(true);
    tf.addFocusListener(new FocusListener() { 
      public void focusGained(FocusEvent e) { System.out.println("JTextField focusGained"); }
      public void focusLost(FocusEvent e)   { System.out.println("JTextField focusLost"); }
    });

    if (useJSplitPane) {
      JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
      splitPane.setTopComponent(tf);
      splitPane.setBottomComponent(new JLabel("foo"));
      getContentPane().add(splitPane, BorderLayout.CENTER);
    } else { // use a JPanel
      JPanel panel = new JPanel(new BorderLayout());
      panel.add(tf, "North");
      panel.add(new JLabel("foo"), "South");
      getContentPane().add(panel, BorderLayout.CENTER);
    } 
  }

 public static void main(String args[]) {
    JSplitPaneFocusBug m = new JSplitPaneFocusBug();
    m.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { System.exit(0); } }); 
    m.setSize(300, 250); m.setLocation(20, 20); m.show();
  }
}
(Review ID: 56311)
======================================================================

Comments
EVALUATION In fact, when I click on the text field after the resize, i don't get a carret -- even though the key events are going to the test field. So the text field never got a focus gained. hania.gajewska@Eng 1999-09-22 This is fixed with the merlin focus work (4290675) combined with the split pane focus bug fix (4374030). Closing as duplicate of 4290675. hania.gajewska@Eng 2001-01-04
22-09-1999