import java.awt.*;
import java.awt.event.*;public class Sco_0401
{
public static void main ( String args[ ] )
{
Frame fr = new Frame( "第一个图形窗口示例" );
fr setLayout( new FlowLayout( ) );
Button button1= new Button( "确定" );
Button button2= new Button( "取消" ); fr.add( button1 );
fr.add( button2 );
fr.setSize( 300,400 );
fr.setBackground( Color.white );
fr.setVisible( true );
fr.addWindowListener( new WindowAdapter()
{ public void windowClosing ( WindowEvent ev )
{ System.exit( 0 );}
});
}
}
请 看红色字体和蓝色字体
import java.awt.*;
import java.awt.event.*; public class Sco_0401
{
public static void main ( String args[ ] )
{
Frame fr = new Frame( "第一个图形窗口示例" );
fr setLayout( new FlowLayout( ) ); //修改为fr.setLayout( new FlowLayout( ) );
Button button1= new Button( "确定" );
Button button2= new Button( "取消" ); fr.add( button1 );
fr.add( button2 );
fr.setSize( 300,400 );
fr.setBackground( Color.white );
fr.setVisible( true );
fr.addWindowListener( new WindowAdapter()
{ public void windowClosing ( WindowEvent ev )
{ System.exit( 0 );}
});
}
}
改成
fr.setLayout( new FlowLayout( ) );
少.号