显示this.show()过时

来源:百度知道 编辑:UC知道 时间:2024/09/28 14:18:46
代码如下
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class buju extends JFrame implements ActionListener
{

int i;
JButton jb=new JButton("0");
JPanel jp=new JPanel();
public buju()
{
this.setTitle("222");
jp.setLayout(new FlowLayout());
jp.add(jb);
jb.addActionListener(this);
this.add(jp);
this.setBounds(300,250,300,200);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
++i;
JButton jbi=new JButton("11"+i);
jp.add(jbi);

this.show(true);

}
public static void main(String args[])
{
buju s=new buju();
}}
显示代码过时,要如何更换this.SHOW()啊

this.setVisable(true);
以后再碰到这种问题,就去网上下个中文API,上面会告诉你,怎么解决这种问题的。用什么方法替代的

先是函数过时只是警告而已。可以不必理会。最菜完美一点的话可以用setVisible替代。。。语句为this.setVisable(true);

用this.setVisable(true);

根据当前版本来

JAVA的语句有些随着版本有变化。

this.setVisible(true);