[kepler-dev] [Ptolemy] XML Viewer under Java 1.5 is too tall: Horizontal scroll bar obscured.

Christopher Brooks cxh at eecs.berkeley.edu
Sun Apr 30 22:35:44 PDT 2006


Ok, this is a strange one.
I modified Top.centerOnScreen() so it calls getSize() and
prints the width and height:

 /** Center the window on the screen.  This must be called after the
   *  window is populated with its contents, since it depends on the size
   *  being known. If this method is called from a thread that is not
   *  the AWT event dispatch thread, then its execution is deferred
   *  and performed in that thread.
   */
    public void centerOnScreen() {
        Runnable doCenter = new Runnable() {
            public void run() {
                Toolkit tk = Toolkit.getDefaultToolkit();
                System.out.println("Top.java: CenterOnScreen: "
                        + getSize().width
                        + " " + getSize().height);

                setLocation((tk.getScreenSize().width - getSize().width) / 2,
                        (tk.getScreenSize().height - getSize().height) / 2);

                // Make this the default context for modal messages.
                GraphicalMessageHandler.setContext(Top.this);
            }
        };

        deferIfNecessary(doCenter);
    }


Under Java 1.4, the output was:
Top.java: CenterOnScreen: 587 754
Top.java: CenterOnScreen: 587 754

Under Java 1.5, the output was:
Top.java: CenterOnScreen: 667 780
Top.java: CenterOnScreen: 667 794

The first question is: Why is centerOnScreen() being
called twice?
The answer is that Tableau.show() calls pack twice:

    /** Make this tableau visible by calling setVisible(true), and
     *  raising or deiconifying its window.
     *  If no frame has been set, then do nothing.
     */
    public void show() {
        JFrame frame = getFrame();

        if (frame != null) {
            if (!frame.isVisible()) {
                size.setSize(frame);

                // NOTE: This used to override the location that might
                // have been set in the _windowProperties attribute.
                /*
                 if (frame instanceof Top) {
                 ((Top)frame).centerOnScreen();
                 }
                 */
                frame.pack();
                frame.setVisible(true);

                // NOTE: The above calls Component.show()...
                // We used to override Top.show() (Top extends JFrame)
                // to call pack(), but this had the unfortunate side
                // effect of overriding manual placement of windows.
                // However, due to some weirdness in Swing or the AWT,
                // calling pack before setVisible() does not have the
                // same effect as calling pack() within show().
                // Calling it after, however, is not sufficient.
                // We have to call it both before and after! Ugh!
                // If this call to pack is put before the call to
                // setVisible(true), then the HTML welcome window
                // when Vergil starts up is the wrong size.
                frame.pack();
            }

            // Deiconify the window.
            frame.setState(Frame.NORMAL);
            frame.toFront();
        }
    }

If I comment out the second frame.pack(), then the problem with XML
View goes away.  Also, it appears that the Welcome Window
has the right size.  I checked in this change, let me know
if it causes probelms for you.  I suspect that the second pack()
might have been added because we were running in the wrong
thread??

_Christopher



--------

    This appears to be a Java 1.5 problem.
    
    Note that the XML Viewer does not have a status bar.  I checked
    Ptolemy II 4.0 and 5.0 and the XML Viewer does not have a status bar,
    though it does have a horizontal scrollbar.
    
    Under Java 1.5.0_06 in the current devel tree, the XML Viewer is
    slightly oversized (too tall) and the horizontal scrollbar
    is partly obscured.
    
    If I recompile with Java 1.4.2_08, then the window is properly
    resized and the horizontal scrollbar is visible.
    
    
    _Christopher
    
    --------
    
        
        In a model, if I select View->View XML, the window that pops up
        has the status bar at the bottom sized incorrectly (almost invisible).
        This looks like the bug we had until recently in the welcome window.
        Any ideas?
        
        Edward
        
        
        ------------
        Edward A. Lee
        Professor, Chair of the EE Division, Associate Chair of EECS
        231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
        phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845
        eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal  
        
        _______________________________________________
        Ptolemy maillist  -  Ptolemy at chess.eecs.berkeley.edu
        http://chess.eecs.berkeley.edu/ptolemy/listinfo/ptolemy
    --------
    _______________________________________________
    Ptolemy maillist  -  Ptolemy at chess.eecs.berkeley.edu
    http://chess.eecs.berkeley.edu/ptolemy/listinfo/ptolemy
--------


More information about the Kepler-dev mailing list