Learning Java object construction process through examples

Source: Internet
Author: User
Learn the Java object construction process through examples-Linux general technology-Linux programming and kernel information. The following is a detailed description. This article provides an example of errors in a Project, provides observation and analysis, reveals the specific process of Java language instantiating an object, and finally summarizes an important rule for designing a Java class. By reading this article, Java programmers can understand the Java object construction process and design more robust code. This article is suitable for Java beginners and Java programmers who need to improve reading.

The program throws an exception.

The author once provided an abstract dialog box base class to project team members in a project. Users only need to implement an abstract method of the base class in the subclass to draw an interface for displaying data, so that the dialog box in the project has the same style. The specific code implementation snippets are as follows (other irrelevant codes are omitted for the sake of conciseness ):
CODE: public abstract class BaseDlg extends JDialog {
Public BaseDlg (Frame frame, String title ){
Super (frame, title, true );
This. getContentPane (). setLayout (new BorderLayout ());
This. getContentPane (). add (createHeadPanel (), BorderLayout. NORTH );
This. getContentPane (). add (createClientPanel (), BorderLayout. CENTER );
This. getContentPane (). add (createButtonPanel (), BorderLayout. SOUTH );
}

Private JPanel createHeadPanel (){
... // Create a dialog box Header
}

// Create the customer region in the dialog box and hand it to the sub-class for implementation.
Protected abstract JPanel createClientPanel ();

Private JPanel createButtonPanel {
... // Create button Area
}
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.