Assignment #43 A Frame with a Panel with Writing on It

Code

      ///Name: Ian Grant
      ///Period:5
      ///Project Name: A Frame with a Panel with Writing on It
      ///File Name:Panel.java
      ///10/23/15
      
      import javax.swing.*;
      import java.awt.*;
      public class Panel
      {
          public static void main (String[] args)
          {
              Frame42 f = new Frame42();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.setVisible(true);
          }
      }
      class Frame42 extends JFrame
      {
          public Frame42()
          {
              setTitle("42 is the answer!");
              setSize(300,200);
              setLocation(100,200);
              hi panel=new hi();
              Container cp=getContentPane();
              cp.add(panel);
          }
      }
      class hi extends JPanel
      {
          public void paintComponent (Graphics g)
          {
              super.paintComponent(g);
              g.drawString("Hi",75,100);
          }
      }
      

Output