import java.awt.*;
import javax.swing.*; 

public class DrawString2D {
    public static void main(String[] args) {
	JFrame frame = new JFrame();

	frame.setSize(500,400);
	frame.setTitle("Draw String");
	frame.getContentPane().setBackground(Color.BLACK);
	
	frame.getContentPane().add(new JPanel(){
		public void paintComponent(Graphics g) {
		    Graphics2D g2 = (Graphics2D) g;
		    setOpaque(false);
		    g2.setPaint(Color.GREEN);
		    Font sansbold14 = new Font("SansSerif", Font.BOLD, 14);
		    g2.setFont(sansbold14);
		    g2.drawString("Hello world!", 100, 100);
		    Font arialitalic16 = new Font("Arial", Font.ITALIC, 16);
		    g2.setFont(arialitalic16);
		    g2.drawString("Hello world!", 100, 250);
		}
	    });


	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setVisible(true);
    }
}


