import java.awt.Container;import javax.swing.*;public class MaximumTest extends JApplet {  
   public void init()
   {
     
      String s1 = JOptionPane.showInputDialog(
         "Enter first floating-point value" );
      String s2 = JOptionPane.showInputDialog(
         "Enter second floating-point value" );
      String s3 = JOptionPane.showInputDialog(
         "Enter third floating-point value" );     
      double number1 = Double.parseDouble( s1 );
      double number2 = Double.parseDouble( s2 );
      double number3 = Double.parseDouble( s3 );      double max = maximum( number1, number2, number3 ); 
    
      JTextArea outputArea = new JTextArea();    
      outputArea.setText( "number1: " + number1 + "\nnumber2: " + 
         number2 + "\nnumber3: " + number3 + "\nmaximum is: " + max );    
      Container container = new Container();//为什么不能改成这样呢?说下具体的原因细节!~ 嗷呜!
     
      container.add( outputArea );   }   
   public double maximum( double x, double y, double z )
   {
      return Math.max( x, Math.max( y, z ) );   } } 

解决方案 »

  1.   

    import java.awt.Container; import javax.swing.*; public class MaximumTest extends JApplet {    
       public void init() 
       { 
          
          String s1 = JOptionPane.showInputDialog( 
             "Enter first floating-point value" ); 
          String s2 = JOptionPane.showInputDialog( 
             "Enter second floating-point value" ); 
          String s3 = JOptionPane.showInputDialog( 
             "Enter third floating-point value" );       
          double number1 = Double.parseDouble( s1 ); 
          double number2 = Double.parseDouble( s2 ); 
          double number3 = Double.parseDouble( s3 );       double max = maximum( number1, number2, number3 );  
         
          JTextArea outputArea = new JTextArea();      
          outputArea.setText( "number1: " + number1 + "\nnumber2: " +  
             number2 + "\nnumber3: " + number3 + "\nmaximum is: " + max );      
         //Container container = new Container();//JApplet当前默认有一个Container对象,你创建了一个新的对象,谁知道呢?
          
          add( outputArea );    }     
       public double maximum( double x, double y, double z ) 
       { 
          return Math.max( x, Math.max( y, z ) );    }  }  
      

  2.   

    那我问下CONTAINER是容器还是JAPPLET是容器?我都不知道哪个是!~~~~~~~`  傲呜!
      

  3.   

    好像没有把Container加到面板上去。。
    你的container.add( outputArea );只是把outputArea 加上去了  但是 Container没有加上去
      

  4.   

    怎么?CONTAINER不是面板吗?难道是容器?嗷呜!
      

  5.   

    container 那它到底就是个什么东西啊//
      

  6.   

    Container container = new Container();//
    为什么不可以呀,
    只要你有时间写把它的那些属性设置了就可以了呀
    只是它是多数容器的基类,一般不那么用而以。
    因为没有必要....
      

  7.   

    JApplet从Applet继承,Applet从Panel继承,Panel从Container继承。
    所以本身就是个Container了。
      

  8.   

    楼主是不是因为运行程序后没有什么显示啊!
    this.getContentPane().add(outputArea);
    是不是就可以了,没有必要再创建一个Container