Method chaining is typically used with the Builder pattern, and you can see this in the StringBuilder
class. Outside of that, method chaining can make the command and creation separation less clear, for instance should repaint()
also be part of the fluent interface? Then I could have:
container.add(label).repaint().setMaximumSize(new Dimension(100,200)));
and suddenly the order of my calls becomes important which can get hidden in the method chaining.