This is main class
package test;
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;
import javax.swing.JFrame;
class Test
{
public static void
main(String args[])
{ String title="ALLAH IS ONE";
for(int
i=0;i<3;i++){
JFrame f= new
JFrame();
f.setSize(200,300);
if(i==2)
f.setTitle(title);
paint P= new
paint();
f.add(P);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}}
//After this create new class of paint and call it in main class
package test;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Ellipse2D;
public class paint extends JComponent {
public void
paint(Graphics g)
{
Graphics2D g2
= (Graphics2D) g;
g2.drawString("An intelligent face", 10, 10);
Ellipse2D.Double E=
new Ellipse2D.Double(4,10,100,149);
g2.setColor(Color.LIGHT_GRAY);
g2.fill(E);
g2.draw(E);
g2.setColor(Color.GREEN);
Rectangle R= new
Rectangle(24,74,20,20);
g2.draw(R);
g2.fill(R);
R.translate(40, 0);
g2.draw(R);
g2.fill(R);
g2.setColor(Color.orange);
Rectangle R1= new
Rectangle(52,94,3,23);
g2.draw(R1);
g2.fill(R1);
Rectangle E2= new
Rectangle(38,128,34,10);
g2.setColor(Color.red);
g2.draw(E2);
g2.fill(E2);
}
No comments:
Post a Comment