To Create an object at runtime
IF I put the declaration of some components into the method of 'actionPerformed',for
JTextArea ErrorMsg=new JTextArea(4,10);
Why it doesn't work?
Re: To Create an object at runtime
This makes ErrorMsg a local variable for that method. You can't refer to it
outside the method, and as soon as the method finishes its local variables
are candidates for garbage collection.
Don't know what you mean by "it doesn't work". Local variables work.
You'll get a compiler error if you try to reference them outside of their
scope. Hope this helps, your question isn't very clear or specific.
Huiyuanm <firstname.lastname@example.org> wrote in message
> IF I put the declaration of some components into the method of
> JTextArea ErrorMsg=new JTextArea(4,10);
> Why it doesn't work?
> Thank you!
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL