ButtonTest.java



import com.nttdocomo.ui.*;
public class ButtonTest extends IApplication
                        implements ComponentListener {

    public Panel first, second;
    public Button next, back;

    public void start() {
        first = new Panel();
        first.setTitle( "最初のパネル" );
        second = new Panel();
        second.setTitle( "次のパネル" );
        Display.setCurrent( first );
       
        next = new Button( "次に進む" );
        next.setForeground( Graphics.getColorOfName( Graphics.RED ) );
        first.add( next );
        first.setComponentListener( this );

        back = new Button( "前に戻る" );
        back.setForeground( Graphics.getColorOfName( Graphics.RED ) );
        second.add( back );
        second.setComponentListener( this );
    }

    public void componentAction( Component source, int type, int param ) {
        if( source == next )
            Display.setCurrent( second );
        else if( source == back )
            Display.setCurrent( first );
    }
}