Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4667544
Votes 23
Synopsis CSH Locks Application When Using Other Than Default Event Queue
Category java:classes_awt
Reported Against 1.4 , 1.4.1
Release Fixed 1.4.2(mantis)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs 4772092 , 4821653 , 4888539
Submit Date 12-APR-2002
Description




FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION : Microsoft Windows 2000
[Version 5.000.2195]


ADDITIONAL OPERATING SYSTEMS : Mandrake Linux 8.0, Solaris
2.8



A DESCRIPTION OF THE PROBLEM :
Subclassing java.awt.EventQueue is handy for logging and
automating the busy cursor.  If you use replace the event
queue with an xxxxx  and invoke context-sensitive help, the
program locks up every time.  I can only speak for what
I've seen in my Swing applications, but context-sensitive
help appears to be the only part that is adversely affected
by replacing the event queue.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Replace the system event queue.  For example, put the
following line at the beginning of main():

  Toolkit.getDefaultToolkit().getSystemEventQueue().push(
    new java.awt.EventQueue() );

In reality, you'd probably push a subclass EventQueue.  But
this demonstrates the problem.

2. Invoke context-sensitive help.
3. Try to click on anything in the application.

EXPECTED VERSUS ACTUAL BEHAVIOR :
I expected the help window to appear and the cursor to
revert back to its original shape.  What happened is the
cursor changed shape as expected (i.e., to the pointer with
the question mark), but subsequent clicks were ignored.
Not only did the help window not come up, the cursor never
reverted back to normal and the application had to be
killed.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import javax.help.*;
import javax.swing.*;

//==============================================================================
// NOTE: For the code to bring up help, you'll need to comment out the event
//       queue portion of main() and create a simple HelpSet called "HelpSet"
//       that has a single target called "textarea".
//==============================================================================

public class HelpDemo extends JFrame {

    private HelpBroker helpBroker; // Manages access to help


    public HelpDemo() {

        addWindowListener( new WindowAdapter() {
            public void windowClosing( WindowEvent e ) {
                System.exit( 0 );
            }
        } );

        initHelpSystem();

        // Create the menu bar.
        JMenuBar menuBar = new JMenuBar();
        setJMenuBar( menuBar );

        // Build the Help menu.
        JMenu menu = new JMenu( "Help" );
        menu.setMnemonic( KeyEvent.VK_H );
        menuBar.add( menu );

        JMenuItem item = new JMenuItem( "Contextual Help" );
        item.setMnemonic( KeyEvent.VK_H );
        item.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F1,ActionEvent.SHIFT_MASK) );
        item.addActionListener(
            new CSH.DisplayHelpAfterTracking(helpBroker) );
        menu.add( item );

        // Add a scrollable area to the window.
        JTextArea textArea = new JTextArea( 5, 30 );
        CSH.setHelpIDString( textArea, "textarea" );
        textArea.setEditable( false );
        textArea.setText( "Click here after invoking context-sensitive help!" );
        JScrollPane scrollPane = new JScrollPane( textArea );
        getContentPane().add( scrollPane, BorderLayout.CENTER );
    }

    /**
     * This method attempts to load the application help.
     */

    private void initHelpSystem() {

        try {
            ClassLoader loader = HelpDemo.class.getClassLoader();
            URL url = HelpSet.findHelpSet( loader, "HelpSet" );

            if ( url == null ) {
                System.err.println( "Can't locate help set!" );
                System.exit( 1 );
            }

            HelpSet helpSet = new HelpSet( loader, url );
            helpBroker = helpSet.createHelpBroker();
            helpBroker.enableHelpKey( getRootPane(), "demo.top", helpSet );

        } catch ( Exception e ) {
            System.err.println( "initHelpSystem(): " + e );
            System.exit( 1 );
        }
    }


    public static void main( String[] args ) {

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// <<<foobar>>> COMMENT THIS OUT TO MAKE CONTEXT-SENSITIVE HELP WORK
        Toolkit.getDefaultToolkit().getSystemEventQueue().push(
            new EventQueue() );
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

        HelpDemo window = new HelpDemo();

        window.setTitle( "Help Demo" );
        window.setSize( 450, 260 );
        window.setVisible( true );
    }
}

---------- END SOURCE ----------
(Review ID: 144983) 
======================================================================
Work Around
N/A
Evaluation
The problem is that the CSH tracking code needs to process the events from the current event queue. Unfortunately when the customer sets the SystemEventQueue to some new queue with call

Toolkit.getDefaultToolkit().getSystemEventQueue().push(new EventQueue());

subsequents calls to

Toolkit.getDefaultToolkit().getSystemEventQueue()

returns the original event queue not the updated queue. This causes JavaHelp CSH to hang because it's looking to process events from the SystemEventQueue but cannot.

I'm passing this on the AWT team to resolve as this appears to be there problem in not returning the pushed EventQueue.

 xxxxx@xxxxx  2002-04-16 

Commit to fix in mantis (hang). 

 xxxxx@xxxxx  2002-04-18





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




The problem is Toolkit.getSystemEventQueue() returns the queue created with
Toolkit even after other queues are pushed over it using
EventQueue.push(...). The idea of the fix is to replace the EVENT_QUEUE_KEY
value in AppContext to the topmost queue in the stack.

======================================================================
Comments
  
  Include a link with my name & email   

Submitted On 16-MAY-2002
netpeaks
Subclass CSH using the sources provided in javahelp.
Remove the search for the default eventQueue and
replace with an externally provided eventQueue


Submitted On 03-OCT-2002
lindamarcella
I'm getting a lot of crashes from calling context-sensitive help 
within a SwingWorker thread, using 
CSH.DisplayHelpAfterTracking(helpBroker).  Tooltips also 
crash/freeze the application.  Could this be why?



PLEASE NOTE: JDK6 is formerly known as Project Mustang