To compile :
javac MyFrame.java
To run:
java MyFrame
Few things must be fixed in order to make it work.
1. add(String, Component) method is obsolete.
change it to add(Component)
2. add main method:
public static void main(String[] args) {
MyFrame f = new MyFrame();
f.setDefaultCloseOperation(JFRAME.EXIT_ON_CLOSE);
f.pack();
f.setVisible(true);
}