简体   繁体   English

在Java netbeans中init(); 用的方法,目的是什么?

[英]In Java netbeans init(); method is used, what is the purpose of it?

I have started work on JFrame in Netbeans. 我已经开始在Netbeans中开发JFrame Actually, I do not have knowledge that Why this init() Function/Method is use in JFrame ? 实际上,我不知道为什么在JFrame使用此init()函数/方法? What is the purpose of it? 目的是什么? Please Explain me about it. 请向我解释一下。

Thanks, 谢谢,

Assuming you're using the Netbeans GUI Builder tool, I think the method you are referring to is the initComponents(); 假设您使用的是Netbeans GUI Builder工具,我认为您所引用的方法是initComponents(); method call that you see in your constructor. 您在构造函数中看到的方法调用。

public class NewJFrame extends javax.swing.JFrame {
    public NewJFrame() {
        initComponents();
    }
}

If you look below the constructor you will see 如果您在构造函数下面看,您将看到

在此处输入图片说明

If you look closely, you will see a + next to line 31. You can expand that code region by pressing the + . 如果仔细观察,您会在第31行旁边看到一个+ 。可以通过按+扩展该代码区域。 When you do, you will see the auto-generated initComponents() method that is called in your constructor. 完成后,您将看到在构造函数中调用的自动生成的initComponents()方法。

在此处输入图片说明

If you look through the method, you will see that's where all of your components are initialized, and the laying out of the components is done. 如果您浏览该方法,将会看到所有组件都已初始化,并且布局了组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM