There is a good example from here.
What you essentially are doing is creating a simple version Interface1 and then adding more functionality to it by create decorations (additional classes) but always ensuring that the decorations have the same interface thus allowing them to be used in the same places as any undecorated items.
From the above link, I've annotated the example.
Take a simple class like window and then decorate it with scroll bars:
// the Window interface
interface Window {
public void draw(); // draws the Window
public String getDescription(); // returns a description of the Window
}
// implementation of a simple Window without any scrollbars
class SimpleWindow implements Window {
public void draw() {
// draw window
}
public String getDescription() {
return "simple window";
}
}
These are the decorators, first an abstract class to with all the common code for the decorator pattern. - note that it implements Window
// abstract decorator class - note that it implements Window
abstract class WindowDecorator implements Window {
protected Window decoratedWindow; // the Window being decorated
public WindowDecorator (Window decoratedWindow) {
this.decoratedWindow = decoratedWindow;
}
public void draw() {
decoratedWindow.draw();
}
}
Now a decoration that adds a Vertical scroll bar to the window. Note it extends WindowDecorator and thus Window and thus the interface Window
// the first concrete decorator which adds vertical scrollbar functionality
class VerticalScrollBarDecorator extends WindowDecorator {
public VerticalScrollBarDecorator (Window decoratedWindow) {
super(decoratedWindow);
}
public void draw() {
decoratedWindow.draw();
drawVerticalScrollBar();
}
private void drawVerticalScrollBar() {
// draw the vertical scrollbar
}
public String getDescription() {
return decoratedWindow.getDescription() + ", including vertical scrollbars";
}
}
Examples of GoF Design Patterns in Java's core libraries has links to lots of other patterns implemented in Java.