import java.awt.*;
import javax.swing.*;
public class displayGraphic extends Canvas
{
public void paint(Graphics g)
{
setBackground(Color.white);
setForeground(Color.red);
g.drawString("Hello",40,40);
g.fillRect(130,30,100,80);
g.drawOval(30,130,50,60);
g.fillOval(130,130,50,60);
g.drawArc(30,200,40,50,90,60);
g.fillArc(30,130,40,50,180,40);
}
public static void main(String surat[])
{
displayGraphic m=new displayGraphic();
JFrame f=new JFrame();
f.add(m);
f.setSize(300,300);
f.setVisible(true);
}
}
Output:
import javax.swing.*;
public class displayGraphic extends Canvas
{
public void paint(Graphics g)
{
setBackground(Color.white);
setForeground(Color.red);
g.drawString("Hello",40,40);
g.fillRect(130,30,100,80);
g.drawOval(30,130,50,60);
g.fillOval(130,130,50,60);
g.drawArc(30,200,40,50,90,60);
g.fillArc(30,130,40,50,180,40);
}
public static void main(String surat[])
{
displayGraphic m=new displayGraphic();
JFrame f=new JFrame();
f.add(m);
f.setSize(300,300);
f.setVisible(true);
}
}
Output:
No comments:
Post a Comment