Take a look at the average "hello world" introduction to Swing (or worse: introduction to Java!)
How many
years does it take one to
fully grasp this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| public class MyFrame extends JFrame implements ActionListener { public static void main(String[] args) { new MyFrame("Hello World"); }
public MyFrame() { JButton b = new JButton("click me"); b.addActionListener(this); this.setLayout(new BorderLayout()); this.add(b, BorderLayout.NORTH); this.pack(); this.setVisible(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public void actionPerformed(ActionEvent event) { System.out.println("you clicked me"); } } |
And why this code crashes or just hangs every once in a while, as we are manipulating Swing from the main thread!
This is very much like how my classmates learned to write their first few lines of Java, when wondering what the difference between an Object, a primitive and a Class was - not to mention Interfaces like ActionListener would be coded 'because the sample code had them'. Anyway... just to show how completely f*cked up most of us (?) got introduced to the wonderful world of programming.
[size=8pt]
Our teacher was to bad, that he had code like MyFrame, MyButton, MyPanel, MyList - just for implementing the event listeners. And when there was nothing to listen for, I stumbled across:
public class MyCheckbox extends Checkbox {
public MyCheckbox() {
super();
}
}
and
public class MyMap extends HashMap {
public MyMap() {
super();
}
public void myPut(Object key, Object value) {
this.put(key, val);
}
}
Okay... that's enough offtopic stuff for today.
[/size]