// different way of writing application based on only JPanel class // main() is in the JPanel package chapter10; import java.awt.Graphics; import java.awt.Color; import javax.swing.*; public class DrawHello2 extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); // to clear the viewing area g.drawString("Hello", 100, 50); } public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(250,130); frame.setTitle("Draw Hello2"); frame.getContentPane().add(new DrawHello2()); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } // chung