Pages

Example of Graphics class and Color class..

import java.awt.*;

class Test extends Frame
{
Test() {
setSize(300,300);
setVisible(true);
setLayout(null);
setTitle("hungry4java");
setBackground(Color.gray);
Color c = new Color(255,0,0);
Graphics g = getGraphics();
g.setColor(c);
g.drawString("Hello welcome to hungry4java.blogspot.com",10,290);
g.drawLine(50,50,100,100);
g.drawRect(150,150,10,10);
g.fillRect(100,100,30,30);
g.drawOval(10,10,100,100);
g.setColor(Color.green);
g.fillOval(200,200,50,50);


}

public static void main(String[] args) {
Test obj = new Test();
}
}

No comments:

Post a Comment