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