Pages

PART 1 Java Source Code : Draw String In Java

This is part one of draw string in java. If you change g.drawString("HI
EVERYONE",10,50); in source code below to g.drawString("HI EVERYONE",10,10); you can't see wording. If you want to see it, you can see part three of draw string in
java.So you can know why you can't see it in this part.

*************************************************************
COMPLETE SOURCE CODE FOR : DrawingText.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 DrawingText extends Frame
{
WindowListener wl=new WindowAdapter()
{
public void windowClosing(WindowEvent evt)
{
System.exit(0);
}
};

public DrawingText()
{
super("Drawing Text");
addWindowListener(wl);
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,50);
}

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


*************************************************************
JUST COMPILE AND EXECUTE IT
*************************************************************
Related Posts Plugin for WordPress, Blogger...