Weirdo
So public static SwitchPLAFAction { ... } is a just java object class
that is really instantied just once, like some sort of singleton?
Actually I have used a modified version of the ActionEvent class from
Kim Topley "Core JFC" example in Xsql as an inner class. So now Xsql can
switch PLAFs too. It works, but I still dont understand public static class ?
I cant find a reference to it in "Exploring Java". I will see if I can
borrow back "Core Java" this weekend.
Pete
______________________________ Reply Separator _________________________________
Subject: Re: Java language question: static classes ?
Author: Ernst.deHaan ([EMAIL PROTECTED]) at lon-mime
Date: 16/10/98 13:08
Correct me if I'm wrong, but I do not believe top-level classes can have
the 'static' modifier applied, but if you want a shared entity, do
something like this:
public class DefaultFactory
extends AbstractFactory
{
protected DefaultFactory() { /* empty */ } // or private if you wish
public final static DefaultFactory SHARED_INSTANCE = new
DefaultFactory();
...
}
This is how I create shared entities (for example in JUMP, a framework for
numeric computations). The only potential problem you have here is
performance, if a piece of code synchronizes on the shared instance. But
then again, _most_ shared entities do not have state, so they should not
have to be synchronized. Malicious code could, however, cause a lifelock
problem by synchronizing on the shared entity and letting go...
GreetinX++, Ernst
Pavel wrote:
> > What is a static class?
> Making classes static has good sense if they are nested. Usually nested
> class object has hidden member referencing high level class object and
> hidden constructor parameters. But static nested class is just like a
> high level class. By the way, static public class nested in another
> public class is the single method I know to define more than one public
> class in one file. I have no idea whether static classes are
> syntaxically allowed on the top level. I think it does not matter -- all
> such classes are actually static in all senses I can image.
>
> Hope this helps.
>
> Pavel