Java Super Keyword Utilization

Source: Internet
Author: User

In the actual development we want to customize the components, we need to inherit from a component class, if we customize this component class also need to like the inherited component class, have a rich construction method.

The role of the keyword super is even more important, you can build your own custom of this component class construction method of the first line to inherit from the parent class construction method;

For example: Java jdialog, I now need to customize a jdialog, can complete the rich function module, then it is obvious that Java itself with the JDialog can not do for us to do this task, it is necessary

Custom JDialog, everyone knows that dialog has a parent form, and that you need to set the dialog modal (modal). You need to pass the parent form and set the modal (modal) in the constructor method of the custom class. Then we

You need to call one of the construction methods of JDialog to see how the development documentation is JDialog constructed:

JDialog(Dialog owner, boolean modal)
Creates a Dialog dialog box with the specified owner and mode.

The Super keyword is required for use.

The text is more boring, on the Code demo bar (Super () keyword must be in the first line of construction method ):

1  Public classChallengerdialogextendsJDialog {2 3 //private int flag=-1;4     /**5 * Create the dialog.6      */7      PublicChallengerdialog (JDialog dialog,string Text) {8         Super(Dialog,true);9 //jpanel.setlayout (null);

Call our Custom

When Challengerdialog:
1 New Challengerdialog (face,challenger+) challenge you, do you accept the challenge? ");

Is it very simple, do you have get\/?

Java Super Keyword Utilization

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.