JavaFAQ Home » Swing, AWT
Question: I just found in Java API LayoutManager LayoutManager2 classess.
Strange naming, does it mean that in future there will be LayoutManager LayoutManager3, LayoutManager LayoutManager4 and even LayoutManager LayoutManager5?
LayoutManager vs LayoutManager2 vs LayoutManager3?
Answer: It is strange indeed. I think it is crisis in the SUN with good names for Java packages and names. David Flanagan in his blog noticed that longest Java name is 36 characters long and there a lot of strange long names, like:
The LayoutManager3 is on its way to us
If speaking seriously, LayoutManager2 is just very light extension of LayoutManager + 5 more methods. It is quite raw class because SUN writes in the API:
This minimal extension to LayoutManager is intended for tool providers who wish to the creation of constraint-based layouts. It does not yet provide full, general support for custom constraint-based layout managers.
The reason why it is appeared is the problem with interfaces -you can't add a method to an interface, you have to use a this funny work around. Otherwise all classes that used the first interface will break
If it were an abstract class, this would not be a problem ( you can add methods without breaking compability). So, probably we will see soon LayoutManager3 when new methods will be developed...
LayoutManager2 Java code example you can find here
Printer Friendly Page
Send to a Friend
Search here again if you need more info!