当前位置: 代码迷 >> J2SE >> 废弃的API解决方案
  详细解决方案

废弃的API解决方案

热度:166   发布时间:2016-04-24 02:18:35.0
废弃的API
请问我这个类编译显示用了或者覆盖了废弃的API,不知道用了哪个废弃的API,大家帮帮忙
import java.awt.*;
class myframe extends Frame
{
private Panel borderpanel;
private Panel gridpanel;
private Panel flowpanel;
private Panel cardpanel;
myframe(String title)
{
super(title);
setSize(300,400);
setLocation(100,100);
setborderlayout();
setflowlayout();
setgridlayout();
setcardlayout();
add(borderpanel);
add(gridpanel);
add(flowpanel);
add(cardpanel);
setLayout(new GridLayout(2,2));


}
public void setborderlayout()
{
Panel borderpanel=new Panel();
borderpanel.setLayout(new BorderLayout());
Button btn1=new Button("East");
Button btn2=new Button("South");
Button btn3=new Button("West");
Button btn4=new Button("North");
Button btn5=new Button("Center");
borderpanel.add(btn1,BorderLayout.EAST);
borderpanel.add(btn2,BorderLayout.SOUTH);
borderpanel.add(btn3,BorderLayout.WEST);
borderpanel.add(btn4,BorderLayout.NORTH);
borderpanel.add(btn5,BorderLayout.CENTER);


}
public void setflowlayout()
{
Panel flowpanel=new Panel();
flowpanel.setLayout(new FlowLayout());
Button btn1=new Button("A");
Button btn2=new Button("B");
flowpanel.add(btn1,"1");
flowpanel.add(btn2,"2");


}
public void setgridlayout()
{
Panel gridpanel=new Panel();
gridpanel.setLayout(new GridLayout(2,3));
Button btn1=new Button();
Button btn2=new Button();
Button btn3=new Button();
Button btn4=new Button();
Button btn5=new Button();
gridpanel.add(btn1);
gridpanel.add(btn2);
gridpanel.add(btn3);
gridpanel.add(btn4);
gridpanel.add(btn5);

}
public void setcardlayout()
{
Panel cardpanel=new Panel();
cardpanel.setLayout(new CardLayout());
Button btn1=new Button("红桃K");
Button btn2=new Button("梅花J");
cardpanel.add(btn1);
cardpanel.add(btn2);

}
public static void main(String []args) throws HeadlessException
{
myframe mf=new myframe("我的架构");
mf.show();
}

}

------解决方案--------------------
mf.show()是废弃方法,改成mf.setVisible(true);
还有你的类名不符合Java命名规范,应该是类名首字母大写
  相关解决方案