
Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
>> Is it safe to use JFrame before the constructor is invoked as in this
>> code
[quoted text clipped - 6 lines]
>> MyClass(){}
>> }
> Your code is safe. Note that you are NOT using a JFrame before it is
> constructed, and that's why it's safe. By the time the initialization
> expression got jdialog has finished, the variable jframe is already
> completely initialized.
I see. And is this safe?
class MyClass extends javax.swing.JFrame
{
javax.swing.JDialog jdialog=new javax.swing.JDialog(this,"MyDialog");
MyClass(){super("MyFrame");}
}
Thomas A. Russ - 13 Feb 2006 18:48 GMT
> I see. And is this safe?
Yes, at least once the accidental change of case gets corrected.
See the Java Language Reference, section 8.3.2.2
"this" can be used in the initializers of class instance variables.
> Class Myclass Extends Javax.Swing.Jframe
> {
> Javax.Swing.Jdialog Jdialog=New Javax.Swing.Jdialog(This,"Mydialog");
> Myclass(){Super("Myframe");}
> }

Signature
Thomas A. Russ, USC/Information Sciences Institute