Name: rl43681 Date: 04/12/2002
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 another 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)
======================================================================