PART 3 Java Source Code : Draw String In Java

This part will show you why when you set g.drawString("HI EVERYONE",10,50); to
g.drawString("HI EVERYONE",10,10); in PART 1, you can't see the wording in frame. This is because wording "HI EVERYONE " is hide at back of frame title. So if you want to see it, you just call method setUndecorated for frame and set it's argument to true. This will make your frame title hide and you can see the wording.

************************************************************
COMPLETE SOURCE CODE FOR : DrawingText3.java
************************************************************


import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;

import java.awt.event.WindowListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class DrawingText3 extends Frame
{
WindowListener wl=new WindowAdapter()
{
public void windowClosing(WindowEvent evt)
{
System.exit(0);
}
};

public DrawingText3()
{
super("Drawing Text");
addWindowListener(wl);
setUndecorated(true);
setSize(400,200);
setVisible(true);
}

public void paint(Graphics g)
{
super.paint(g);
g.setFont(new Font("Serif",Font.BOLD,12));
g.setColor(Color.BLACK);

g.drawString("HI EVERYONE",10,10);
}

public static void main(String[]args)
{
DrawingText3 dt=new DrawingText3();
}
}


************************************************************
JUST COMPILE AND EXECUTE IT
************************************************************

RELAXING NATURE VIDEO