Cannot read field “parent“ because “comp“ is null

public class addreader extends JFrame {
    private JButton addreaderButton;
    private JLabel id,name,ic,tel;
    private JTextField readerid,readername, readeric,readertel;
    private JPanel idPanel,namePanel,icPanel, ridPanel,telPanel,buttonPanel;
                                                //这里的ridPanel是多余的,把这里删掉

    public addreader() {
        this.setLayout(new GridLayout(5,1));
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        idPanel = new JPanel(new FlowLayout());
        namePanel = new JPanel(new FlowLayout());
        icPanel = new JPanel(new FlowLayout());
        telPanel=new JPanel(new FlowLayout());
        buttonPanel = new JPanel(new FlowLayout());
        prepareUi();
    }
    public void showUi() {
        buttonPanel.add(addreaderButton);

        idPanel.add(id);
        idPanel.add(readerid);

        namePanel.add(name);
        namePanel.add(readername);

        icPanel.add(ic);
        icPanel.add(readeric);

        telPanel.add(tel);
        telPanel.add(readertel);

        this.add(idPanel);
        this.add(namePanel);
        this.add(icPanel);
        this.add(ridPanel);//这个多余,把这个删掉
        this.add(telPanel);
        this.add(buttonPanel);

        this.pack();
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }
    private void prepareUi() {
        id = new JLabel("读者编号:");
        id.setFont(new Font("宋体",0,20));
        readerid = new JTextField();
        readerid.setFont(new Font("宋体",0,20));
        readerid.setColumns(30);

        name = new JLabel("姓名:");
        name.setFont(new Font("宋体",0,20));
        readername = new JTextField();
        readername.setFont(new Font("宋体",0,20));
        readername.setColumns(30);

        ic = new JLabel("身份证号:");
        ic.setFont(new Font("宋体",0,20));
        readeric = new JTextField();
        readeric.setFont(new Font("宋体",0,20));
        readeric.setColumns(30);

        tel  = new JLabel("电话号码:");
        tel.setFont(new Font("宋体",0,20));
        readertel = new JTextField();
        readertel.setFont(new Font("宋体",0,20));
        readertel.setColumns(30);

        addreaderButton = new JButton("添加");
        addreaderButton.setSize(8,20);
        addreaderButton.setFont(new Font("宋体",0,20));
        addreaderButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                addReaderButtonActionPerformed(e);
            }
        });
    }
}

解决办法如代码注释所示,把“ridPanel”和“this.add(ridPanel)删掉,成功执行。

extends :继承一个已有的类,被继承的类称为父类 (超类,基类),新的类称为子类 (派生类)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Introduction When I started this project, I had two requirements and I strived throughout the book to balance both of them. My first requirement comes from being an instructor and consultant for 10 years now. In that time, I have found a consistent void with most of my students and clients. It is not that clients are unwilling to implement new technologies. It is not that students are unable to learn about new technologies. The void is between those two. You learn about new technologies, but often the knowledge you gain does not provide a solid understanding of where in the network the new technology resides. You get design models, learn commands to turn features on and off, but you don’t know where to locate the device or why to implement a particular application or feature. For this reason, I have written this book in the form of a single case study that runs through the entire book. The case study revolves around a single, fictitious company that I created for the sole purpose of explaining where and why technologies should be placed in a real network. I hope that they do not become just objectives in a book for you to memo- rize. The Real World Scenarios are designed to trigger your thought process and allow you to find practical applications in your own networks. Speaking of objectives, this brings me to the second requirement for the book. That requirement is to fill a hole in having a single source of information, a place to learn about all of the common technologies used by network engineers today. To provide an outline for those common technologies, I used the objectives in place as of January 2009 for the Cisco Certified Network Professional (CCNP) certification. It would be difficult to cover every single objective from this certification track in one book, but you will find I have covered a vast majority of the objectives. My hope is that you will find this book a valuable supplemental guide in your studies as you endeavor to attain the coveted CCNP certification. The challenge was getting as many technologies into the book with enough detail so you would to know where and how to use them. There is not enough room in a single book to cover every possible solution or every single command and option you could use to accomplish a task. I do recommend some of the best and most common ways to accomplish the tasks. On that note, I hope that my coverage of wireless technologies in the last two chapters of the book will pique your interest in the exciting new technologies in wireless LANs. If you want a more in-depth fundamental look at how wireless networks operate and all of the fun, new toys (I mean wireless devices) that you can use to implement them, then watch for the new CCNA wireless book that Todd Lammle and I are currently writing for Sybex. Who Should Read This Book I highly recommend to anyone reading this book to have their CCNA certification or a firm understanding of the objectives and concepts covered. I put so many technologies into this one book, and covered as much of the CCNP material as possible that I didn’t have the space required to review all of the CCNA material. 83605book.indd 25 3/26/09 11:26:31 AM xxvi Introduction How to Use This Book This book not only covers many exciting and complex networking topics but shows you the steps required to design a full corporate internetwork. If you follow the chapters in order, I walk you not only through building single VLANs and subnets but through the security, voice, QoS, and wireless technologies you need to implement an entire campus network. How This Book Is Organized In Chapter 1, I provide for you an explanation of Cisco’s current design methodologies. This includes a discussion on Cisco’s Enterprise Composite Design Model and how that model has evolved over the years. Even a little bit about where it may go in the future. Following the design section of Chapter 1, I break down for you in detail what you can expect to accomplish in each chapter of the book and explain why I organized the book the way I did. After that, I describe for you the case study that is the framework for the book. This includes background of FutureTech, Inc., the network layout that the company has, and the technologies you are going to implement over the course of the book. You will be acting as the senior network engineer for the company (or the highly paid expert consultant that helps them through the process, if that sounds better to you). The last thing that I cover in Chapter 1 is the equipment and lab setup you can use to test and practice the technologies and topics you go through in the book. I will give you a breakdown of the topology that I will be using and supplemental equipment that can be used in exchange for the equipment that I have in my setup. With those details out of the way, I jump right into helping you build your network. Chapter 2 provides the lowdown on switching. Here you get a look at Layer 1 and Layer 2 functionality and access layer devices, creating a strong foundation from which to build the rest of the network. Then, I get into some Layer 3 functions with inter-VLAN routing. In Chapter 3, I walk you through controlling the topology and your connections. By the time you’ve finished Chapter 3 you will understand all of the functions of STP and how it prevents broadcast storms, multiple frame copies, and protects the stability of the MAC address table. In Chapters 4 through 7, you learn specifically about the routing process itself and how to give routers the information they require. I cover both static and dynamic routing protocols in depth, along with ways to filter and control the propagation of routing information between routers and routing domains. I also provide you with the means to verify and troubleshoot your network connections. Chapters 8 through 10 teach you about protocols and functions that make your net- work more reliable and efficient. In Chapter 8, I cover multicast. Here you learn what makes multicast work and see some of the configurations available to help you cope with increased use of applications and programs that send large amounts of data to a whole group of users. Continuing in this vein in Chapter 9, I give you the nuts and bolts of Inter- net Protocol version 6 (IPv6). In Chapter 10, I show you how to provide redundancy and load balancing features to your network using just your routers. You learn to configure and use HSRP, VRRP, and GLBP
根据引用\[1\]中的代码,当判断对象"parent"是否为null时,如果为null,则返回空字符串。否则,返回对象的"name"属性。所以,根据引用\[1\]的代码,当对象"parent"为null时,不会出现"Cannot read field "parent" because "comp" is null"的错误。 引用\[2\]中的代码是Java代码,与问题中的引用内容无关。 引用\[3\]中的代码是一个表格的列定义,与问题中的引用内容无关。 综上所述,根据提供的引用内容,无法回答问题"Cannot read field "parent" because "comp" is null"。请提供更多相关的信息。 #### 引用[.reference_title] - *1* *3* [表自关联时,解决列表显示顶级对象出现“Cannot read property 'xxx' of null”的问题...](https://blog.csdn.net/weixin_30438813/article/details/96794721)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [(栈,头插法、双指针法)反转链表(reverseList)Leetcode19](https://blog.csdn.net/weixin_52034121/article/details/122696246)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值