JDK-5062118 : REGRESSION:disabling of a JFrame appears to effect the event handling
  • Type: Bug
  • Status: Resolved
  • Resolution: Fixed
  • Component: client-libs
  • Sub-Component: java.awt
  • Priority: P3
  • Affected Version: 5.0
  • OS: linux
  • CPU: x86
  • Submit Date: 2004-06-11
  • Updated Date: 2004-12-21
  • Resolved Date: 2004-12-21
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 Availabitlity Release.

To download the current JDK release, click here.
Other JDK 6
5.0u2 b04Resolved 6Resolved
Related Reports
Duplicate :  
Relates :  
Description
###@###.### 2004-06-11

J2SE Version (please include all output from java -version flag):
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
  Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)

Does this problem occur on J2SE 1.4 or 1.4.1 or 1.4.2?  Yes / No (pick one)
  No.  Also doesn't occur with the JDK 1.5.0 in Windows or Solaris.

Operating System Configuration Information (be specific):
  RedHat Linux 8.0

Hardware Configuration Information (be specific):
  Pentium II 133MHz 64MB RAM

Bug Description:
  The disabling of a JFrame in JWindows appears to effect the event 
  handling in an independent JWindow.  This problem only occurs in 
  Linux and the JDK 1.5.0.

Steps to Reproduce (be specific):

1) Compile the class JDK150LinuxBug using the JDK 1.2.2 or 1.4.2
2) execute JDK150LinuxBug.class using the JDK 1.5.0 in Linux.
3) Clicking on the "Click to Close Me" button has no effect.
  
However, clicking on the button will close its window if
   a) you execute in Linux using the JDK 1.3 or 1.4 OR
   b) you use the JDK 1.5.0 in Windows or Solaris OR
   c) you comment out the "frame.setEnabled(false);" line.

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

public class JDK150LinuxBug extends JWindow {

   JButton okBtn;
   Frame parent;
   Thread timer;

   public JDK150LinuxBug(final Frame parent) {
      super(parent);
      this.parent = parent;
      setupGUI();
      setLocation(100, 100);
      setVisible(true);
   }

   synchronized void close() {
      setVisible(false);
      dispose();
   }

   public void setupGUI()
  {
      okBtn = new JButton("Click to Close Me");
      Container contentPane = getContentPane();
      contentPane.setLayout(new BorderLayout());
      contentPane.add(okBtn);
      setSize(250, 250);
      MouseListener mouseListener = new MouseAdapter() {
         public void mousePressed(MouseEvent ev) {
            System.out.println("MousePressed ");
            close();
         }
      };
      okBtn.addMouseListener(mouseListener);
      okBtn.requestFocus();
   }

   public static void main(String[] args) {
      final Frame frame = new Frame();
      frame.setSize(100, 100);
      frame.setVisible(true);
      frame.setEnabled(false); //Comment this line out to work around bug
      JDK150LinuxBug window = new JDK150LinuxBug(frame);
   }
}
//////////////////////////////

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon mustang
2004-09-11

EVALUATION This is specific to Linux. Likely an AWT problem. ###@###.### 2004-06-11 Name: ynR10250 Date: 06/16/2004 This is XAWT-specific bug. In XComponentPeer, getParent() loop does check if any of the parents is disabled; however in this case the topmost parent is another toplevel. We should check for this situationi here and elsewhere. ###@###.### ======================================================================
2004-09-11

SUGGESTED FIX That's how it was fixed in Mustang and perhaps in update release of 1.5.0 *** /awt/yan/child2/webrev.5062118/src/solaris/classes/sun/awt/X11/XComponentPeer.java- 2004-09-06 16:34:54.000000000 +0400 --- /awt/yan/child2/webrev.5062118/src/solaris/classes/sun/awt/X11/XComponentPeer.java 2004-09-06 16:34:54.000000000 +0400 *** 126,142 **** } enabled = target.isEnabled(); // If any of our ancestors are disabled, we should be too ! Component parent = target.getParent(); ! while (parent != null) { ! if (!parent.isEnabled()) { setEnabled(false); break; } - parent = parent.getParent(); } enableLog.log(Level.FINE, "Initial enable state: {0}", new Object[] {Boolean.valueOf(enabled)}); if (target.isVisible()) { show(); --- 126,142 ---- } enabled = target.isEnabled(); // If any of our ancestors are disabled, we should be too ! Component comp = target; ! while( !(comp == null || comp instanceof Window) ) { ! comp = comp.getParent(); ! if( comp != null && !comp.isEnabled() ) { setEnabled(false); break; } } enableLog.log(Level.FINE, "Initial enable state: {0}", new Object[] {Boolean.valueOf(enabled)}); if (target.isVisible()) { show(); ###@###.### 10/21/04 06:42 GMT
4-10-21 00:00:00