This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug AWT/19861] New: Swing JOptionPane without parent frame


The following testcase shows a (subtle) problem in the Swing rendering strategy.
A JOptionPane dialog without any parent works fine, but a JOptionPane
attached to a non-showing parent (e.g. JFrame) fails with an 
IllegalComponentStateException. Because the Exception blocks the Swing
redraw thread, there is no way to recover from the illegal state.

(both dialog windows work fine under JDK 1.4.2, not tested with other versions).


/* NoParentJOptionPane.java
 *
 * demonstrates GCJ doesn't like dialogs without visible parents...
 *
 * (C) 2005 FNH
 */

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

public class NoParentJOptionPane {

  public static void main( String args[] ) {
    String s = "Testing JOptionPane w/o parent...";

    System.out.println( "The first call works: null parent:" );
    JOptionPane.showMessageDialog( null, s );

    // JDK1.4+ runs this, gcj complains about:
    // java.awt.IllegalComponentStateException: component not showing
    // at java.awt.Component.getLocationOnScreen() 
    // at javax.swing.SwingUtilities.convertPointToScreen(java.awt.Point,
java.awt.Component) 
    // at javax.swing.SwingUtilities.convertPoint(java.awt.Component, int, int,
java.awt.Component) (/usr/lib/lib-javax-swing.so.0.0.0)
    // ...
    JFrame frame = new JFrame( "just a hidden frame" );

    System.out.println( "The second call is broken: frame parent" );
    JOptionPane.showMessageDialog( frame, s );

    System.exit( 0 );
  }

}

-- 
           Summary: Swing JOptionPane without parent frame
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: AWT
        AssignedTo: fitzsim at redhat dot com
        ReportedBy: hendrich at informatik dot uni-hamburg dot de
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19861


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]