A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 曹世明 中级黑马   /  2013-5-20 16:23  /  1102 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

import java.awt.*;
class shuchu
{        public static void main(String []args)
        {
        Frame f=new Frame("a wat");
        f.setSize(500,400);
        f.location(200,200);//此处报错,求解答
        Button b=new Button("按钮");
        f.setLayout(new FlowLayout());
        f.add(b);
        f.setVisible(true);

        }
}

评分

参与人数 1技术分 +1 收起 理由
殇_心。 + 1

查看全部评分

2 个回复

倒序浏览
是f.locate(200,200);
回复 使用道具 举报
  1. import java.awt.*;
  2. class shuchu
  3. {        public static void main(String []args)
  4.          {
  5.          Frame f=new Frame("a wat");
  6.          f.setSize(500,400);
  7.          //f.location(200,200);//已过时。 从 JDK version 1.1 开始,由 getLocation() 取代。而且location()方法并没有location(int x, int y)的重载形式。
  8.          //f.location();//这句可以编译通过,但已过时不推荐使用,相当于getLocation()方法,返回一个位置对象Point
  9.          f.setLocation(200,200);//如果需要设置窗体的初始位置,可以使用setLocation(int x, int y)方法。
  10.         Button b=new Button("按钮");
  11.          f.setLayout(new FlowLayout());
  12.          f.add(b);
  13.          f.setVisible(true);
  14.          }
  15. }
复制代码
黑马云青年为您解答。:D

点评

强烈鄙视刷广告滴!! 嘿嘿```  发表于 2013-5-20 18:20

评分

参与人数 1技术分 +1 收起 理由
殇_心。 + 1

查看全部评分

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马