frame.show();//这个方法被deprecated,也就是说被废弃了,应该用setVisible(true);第二个警告不知道怎么回事

解决方案 »

  1.   

    fpack.CalculatorFrame 你这个变量可能不再推荐使用了,但一般的软件是向后兼容的,所以你可以运行。
      

  2.   

    这样写将这行注释掉 //package fpack;
    将方法CalculatorFrame 改成 TT_CalculatorFrame然后用javac -d . -Xlint testCalculator.java
    警告没变。
    看来不是package的问题,是我说错了。  
    而frame.show()确实是不被推荐使用的。
    有谁补充吗?
      

  3.   

    可是,我想弄清楚第二个警告是什么意思?
    testCalculator.java:17: warning: [serial] serializable class fpack.CalculatorFrame has no definition of serialVersionUID
    class CalculatorFrame extends JFrame难道说JFrame类也不被推荐了?顺便说一下,我是用的java 1.5
      

  4.   

    serialVersionUID is used to determine whether the version of a class being read from a serialization source is the same as that written. You can define your own but if you don't the compiler creates one for you. Java 1.5 emphasizes the dangers of the latter option
    http://java.sun.com/j2se/1.5.0/docs/guide/serialization/relnotes15.html
    http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html
    http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/serialTOC.html
    simply you  can add 
    public static final long serialVersionUID = 123456789L;// just a long
    to your class.
      

  5.   

    serialVersionUID is used to determine whether the version of a class being read from a serialization source is the same as that written. You can define your own but if you don't the compiler creates one for you. Java 1.5 emphasizes the dangers of the latter option
    http://java.sun.com/j2se/1.5.0/docs/guide/serialization/relnotes15.html
    http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html
    http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/serialTOC.html
    simply you  can add 
    public static final long serialVersionUID = 123456789L;// just a long
    to your class.
      

  6.   

    第二个警告说得是序列化问题。意思是没有定义序列化版本号。如果你用jdk1.4应该不会出现这个警告吧。
    jdk1.5没用过,可能在安全性方面有很多提高。
      

  7.   

    你把frame.show();换成frame.serVisible(true);就不会有第一个警告了。
      

  8.   

    谢谢大家,问题解决。
    把frame.show();换成frame.serVisible(true) 
    把public static final long serialVersionUID = 123456789L;(随便一个数)加到类CalculatorFrame 中。目的是兼容java 1.1.x