JDK-4169941 : JDK 1.1.7/JDK 1.2 forms font is inconsistency
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 1998-08-28
  • Updated: 1998-09-14
  • Resolved: 1998-09-14
Related Reports
Duplicate :  
Relates :  
Description
ingrid.yao@Eng 1998-08-28

When you run the following test program under JDK 1.2 you will see that 
the font metrics returned for the forms font is different then that 
returned under JDK 1.1.7. It only happen after JDK1.2beta4 i.e., J
DK1.2beta4.1 and JDK1.2fcs. - sounds like a regression bug.

Test program: t1.java and Form1.java
=============
/*
    t1.java

    NOTE: This file is a generated file.
          Do not modify it by hand!
*/
// add your custom import statements here

class t1 extends Object
{
    public t1()
    {
        super();
    }
    public static void main(String args[])
    {
        t1 app = new t1();
        app.StartApp(args);
        app.RunApp(args);
        app.EndApp(args);
    }
    public void StartApp(String args[])
    {
    }
    public void RunApp(String args[])
    {
        CreateMainForm();
    }
    public void EndApp(String args[])
    {
    }
    public Form1 CreateMainForm()
    {
        Form1 form = new Form1();
        form.setMainForm(true);
        try {
            form.create();
        }
        catch ( java.lang.Exception __e ) {
            __e.printStackTrace();
        }
        return form;
    }
    // add your data members here

}


Form1.java
----------
/*
    Form1.java

    NOTE: This file is a generated file.
          Do not modify it by hand!
*/

// custom imports for Form1
// add your custom import statements here



class Form1 extends java.awt.Frame implements java.awt.event.WindowListener
{
    public java.awt.Rectangle DURectangle( int x, int y, int w, int h )
    {
        String        alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        java.awt.FontMetrics   fm = getFontMetrics( getFont() );
        double        fw = ( fm != null ) ? ( fm.stringWidth( alphabet ) / alphabet.length() ) : 0;
        double        fh = ( fm != null ) ? ( fm.getHeight() / 2.0 ) : 0.0;

	System.out.println( fm );

        return new java.awt.Rectangle( (int) Math.round( ( (double)fw * (double)x ) / 4.0 ),
                              (int) Math.round( ( (double)fh * (double)y ) / 4.0 ),
                              (int) Math.round( ( (double)fw * (double)w ) / 4.0 ),
                              (int) Math.round( ( (double)fh * (double)h ) / 4.0 ) );
    }

    public void DUPositionComponent( java.awt.Component comp, int x, int y, int w, int h, java.awt.Insets formInsets )
    {
        java.awt.Rectangle     rect = DURectangle( x, y, w, h );
        if( (comp != this) && (formInsets != null) ) {
            rect.x += formInsets.left;
            rect.y += formInsets.top;
        }
        if( (comp == this) && (formInsets != null) && (formInsets.bottom > 0) ) {
            rect.height += formInsets.bottom;
        }
        comp.setBounds( rect );
    }

    public void setMainForm( boolean isMainForm )
    {
        __mainForm = isMainForm;
    }
    public boolean isMainForm()
    {
        return __mainForm;
    }
    public boolean create() throws java.lang.Exception
    {
        setResizable(true);

        java.awt.Container contentPane = getContentPane();
        java.awt.Font defaultFont = new java.awt.Font( "Dialog", java.awt.Font.PLAIN, 12 );
        setFont( defaultFont );

        boolean retval = true;
        addNotify();

        java.awt.Insets formInsets = (java.awt.Insets)(contentPane.getInsets().clone());
        contentPane.setBackground( java.awt.Color.lightGray );
        contentPane.setForeground( java.awt.Color.black );

        contentPane.setLayout( null );
        contentPane.add( (java.awt.Component)cb_1 );
        contentPane.add( (java.awt.Component)lb_1 );
        DUPositionComponent( (java.awt.Component) this, 46, 94, 263, 228, formInsets );
        addWindowListener(this);

        try {
            DUPositionComponent( cb_1, 25, 25, 40, 14, formInsets );
            cb_1.setLabel( "hello" );
            cb_1.setFont( defaultFont );
            cb_1.setBackground( java.awt.Color.lightGray );
            cb_1.setForeground( java.awt.Color.black );
            cb_1.setEnabled(true);
            cb_1.setVisible(true);

        }
        catch( java.lang.Exception e_cb_1 ) {
            e_cb_1.printStackTrace();
        }
        try {
            lb_1.addItem( "first" );
            lb_1.addItem( "second" );
            lb_1.addItem( "third" );
            lb_1.addItem( "fourth" );
            lb_1.addItem( "fifth" );
            DUPositionComponent( lb_1, 85, 50, 135, 120, formInsets );
            lb_1.setFont( defaultFont );
            lb_1.setBackground( java.awt.Color.white );
            lb_1.setForeground( java.awt.Color.black );
            lb_1.setEnabled(true);
            lb_1.setVisible(true);

        }
        catch( java.lang.Exception e_lb_1 ) {
            e_lb_1.printStackTrace();
        }

        setVisible(true);
        return retval;
    }

    public synchronized boolean destroy()
    {
        if( (java.awt.Container)this instanceof java.awt.Window ) {
            ((java.awt.Window)(java.awt.Container)this).dispose();
        } else {
            removeNotify();
        }
        if( isMainForm() ) {
            System.gc();
            System.runFinalization();
            System.exit(0);
        }
        return true;
    }


    public void windowClosed( java.awt.event.WindowEvent event )
    {
    }
    public void windowOpened( java.awt.event.WindowEvent event )
    {
    }
    public void windowClosing( java.awt.event.WindowEvent event )
    {
        java.lang.Object eventTarget = event.getSource();
        if( eventTarget == this ) {
            Form1_windowClosing( event );
        }
    }
    public void windowIconified( java.awt.event.WindowEvent event )
    {
    }
    public void windowActivated( java.awt.event.WindowEvent event )
    {
    }
    public void windowDeiconified( java.awt.event.WindowEvent event )
    {
    }
    public void windowDeactivated( java.awt.event.WindowEvent event )
    {
    }
    public Form1()
    {
        super();
    }
    public java.awt.Container getContentPane()
    {
        //  Use the following if you inherit from a JFC container such as com.sun.java.swing.JFrame
        //  return super.getContentPane();
        return this;
    }
    public boolean Form1_windowClosing(java.awt.event.WindowEvent event)
    {
        
        setVisible(false);
        destroy();
        return false;
    }
    /****************************************
     * data members
     ****************************************/

    protected boolean __mainForm = false;




    protected java.awt.Button  cb_1 = new java.awt.Button();
    protected java.awt.List  lb_1 = new java.awt.List();

    // add your data members here

}




Comments
PUBLIC COMMENTS not a bug. metrics are not guaranteed to be consistent from machine to machine, or from build to build. paul.charlton@eng 1998-09-13 the crash, if reproducible in a later build, should be assigned to the awt group. It is not reproducible in the current workspace. paul.charlton@eng 1998-09-13
13-09-1998

EVALUATION There is no constraint that font metrics will remain unchanged between releases. This is not a regression bug. Is there some other problem with the metrics other than the simple fact that they changed? If not, this is "not a bug". jim.graham@Eng 1998-08-31 email has sent to Sybase on 8/31, so far no response from Sybase ingrid.yao@Eng 1998-09-02 ping sybase again, but no response. I will close this bug now until hear any further concerns from licensee. ingrid.yao@Eng 1998-09-09
02-09-1998