Topic: 请教:一个程序问题(类中类,gui)

  Print this page

1.请教:一个程序问题(类中类,gui) Copy to clipboard
Posted by: redcolor
Posted on: 2007-04-20 15:06

import java.awt.*;
import java.awt.event.*;

public class lyt1
{
  public static void main(String[] args)
  {
      new FrameInOut();

  }
}

/*
class FrameInOut extends Frame implements ActionListener
{
  
   Label prompt;
  TextField input,output;
    Button btn;
  
   FrameInOut()
   {
     super("图形界面的JAVA成学");
     prompt=new Label("please input your name");
     input=new TextFieldDevil;
     output=new TextField(20);
       btn=new Button("关闭");
       setLayout(new FlowLayout( ));
     add(prompt);
     add(input);
     add(output);
       add(btn);
     input.addActionListener(this);
       btn.addActionListener(this);
       setSize(300,200);
       show();
  

   }
  public void actionPerformed(ActionEvent e)
  {
    if(e.getSource()==input)
    output.setText(input.getText()+"hello");
    //System.out.println("Hello World!");
    else
    {
      dispose();
      System.exit(0);
    }
  }
}
*/
这样编译时候就不出现问题,但是注释的部分也运行了。
当去掉注释后出现:
注意:lyt1.java使用或覆盖了已过时的API
注意:要了解详细信息,请使用-xlint:deprecation重新编译
请问为什么注释的部分也能运行?去了注释后为什么会出现这个问题?
谢谢!

2.Re:请教:一个程序问题(类中类,gui) [Re: redcolor] Copy to clipboard
Posted by: 112233445566
Posted on: 2007-04-20 23:06

看看

3.Re:请教:一个程序问题(类中类,gui) [Re: redcolor] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2007-04-22 06:16

redcolor wrote:
请问为什么注释的部分也能运行?
谢谢!

You must have compiled your code already i.e. *FrameInOut.class* has already been generated in your current working directory or your target directory. You are actaully using some stale class which could cause some unpredictable problems. Delete the class file and re-compile your code with the comment of the *FrameInOut.class*, the compiler will definately give you errors.

redcolor wrote:
去了注释后为什么会出现这个问题?

Some API has been marked *deprecated* by the Sun microsystems during the evolution of Java. Using a newer compiler to compiler the old deprecated API will throw out this warning.

BTW, there is nothing to do with INNER CLASS at all in your code.

4.Re:请教:一个程序问题(类中类,gui) [Re: redcolor] Copy to clipboard
Posted by: redcolor
Posted on: 2007-04-23 17:35

thx


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923