| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1790 人关注过本帖
标题:为什么图中没有button与喵喵
只看楼主 加入收藏
wancy
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2016-5-27
结帖率:25%
收藏
已结贴  问题点数:20 回复次数:1 
为什么图中没有button与喵喵
public static void main(String[] args)
    {
        JFrame jframe=new JFrame();
        jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jframe.setTitle("wancy GUI");
        jframe.setLayout(null);
        jframe.setBounds(0,0,400,400);
        //jframe.getContentPane().setBackground(Color.CYAN);
        JTextArea j=new JTextArea("喵喵");
        jframe.add(j);
        JButton b=new JButton("wancy");
        jframe.add(b);
        jframe.setVisible(true);
    }
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: button public null 喵喵 
2016-06-07 20:07
zzjvslove
Rank: 3Rank: 3
等 级:论坛游侠
威 望:3
帖 子:46
专家分:197
注 册:2016-5-23
收藏
得分:20 
你把jframe的Layout设置成null。
你的JButton与JTextArea 就要设置相对于JFrame的位置、用绝对定位。
如:j.setBounds(x,x,x,x)   
    b.setBounds(x,x,x,x)   
2016-06-08 00:15
快速回复:为什么图中没有button与喵喵
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017781 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved