标题:请高手帮我看看
取消只看楼主
sql377288
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-1-16
 问题点数:0 回复次数:0 
请高手帮我看看
import java.awt.*;
import javax.swing.*;
class Link extends JFrame{
    public static final int ROW=6;
    public static final int COL=7;
    private JPanel p1=new JPanel();
    private JPanel p2=new JPanel();
    private JButton[][] button=new JButton[ROW][COL];
    public Link(){
        this.setSize(600,500);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLayout(new BorderLayout());
        p1.setBackground(Color.BLUE);
        p1.setLayout(new GridLayout());
        p1.setPreferredSize(new Dimension(500,500));
        
        for(int i=0;i<ROW;i++){
            for(int j=0;j<COL;j++){
                button[i][j]=new JButton();
                p1.add(button[i][j]);
            }
        }
        p2.setBackground(Color.YELLOW);
        p2.setPreferredSize(new Dimension(100,500));
        
        this.add(p1,BorderLayout.CENTER);
        this.add(p2,BorderLayout.EAST);
        
        this.setVisible(true);
        
    }

}
运行时老是提行:Exception in thread "main" java.lang.NullPointerException
搜索更多相关主题的帖子: private public import 
2015-05-10 11:32



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-445093-1-1.html




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

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