initclass bug

[email protected] Fri, 20 May 2005 14:26:47 -0300
Newsgroups gmane.comp.embedded.carlsbad-cubes
Message-ID <[email protected]>
Hi,

I am trying to use an initclass like the following:

<formattedtextfield columns="5"
initclass="java.text.SimpleDateFormat(hh)"/>

However, it is not working. 

I made the following test to display what I think is a bug. The first
textfield were created from the above XML as-is, and the second from
Swing. Swixml doesn't work correctly in that case as follows:

import java.text.SimpleDateFormat;
import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.swixml.SwingEngine;

public class Test
{
    public static void main(
        String[] args )
    {
        new Test().doit();
    }

    public void doit()
    {
        SwingEngine se = new SwingEngine( this );
        JFrame f = new JFrame();
        JPanel p = new JPanel();
        JFormattedTextField tf = new JFormattedTextField();
        try {
            tf = (JFormattedTextField) se.render( "br/com/test/Test.xml" );
        } catch( Exception e ) {
            System.err.println( e.getMessage() );
        }
        SimpleDateFormat s = new SimpleDateFormat( "hh" );
        JFormattedTextField tf2 = new JFormattedTextField( s );
        tf2.setColumns( 5 );
        p.add( tf );
        p.add( tf2 );
        p.add( new JButton( "Test" ) );
        f.add( p );
        f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        f.pack();
        f.setVisible( true );
    }
}

Thanks again.

.mi