This is the beginning of the MidiSynth class from the Java Sound Demo. I was under the impression that methods in Java were always called from an object or a class. Where does the setLayout() method come from here?
public class MidiSynth extends JPanel implements ControlContext {
// Fields omitted
public MidiSynth() {
setLayout(new BorderLayout());
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
EmptyBorder eb = new EmptyBorder(5,5,5,5);
BevelBorder bb = new BevelBorder(BevelBorder.LOWERED);
CompoundBorder cb = new CompoundBorder(eb,bb);
p.setBorder(new CompoundBorder(cb,eb));
JPanel pp = new JPanel(new BorderLayout());
pp.setBorder(new EmptyBorder(10,20,10,5));
pp.add(piano = new Piano());
p.add(pp);
p.add(controls = new Controls());
p.add(new InstrumentsTable());
add(p);
}
MidiSynth extends JPanelSo the
setLayoutcall is actually invokingthis.setLayout