import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class Circle extends JFrame
{
Dimension d;
public Circle()
{
setSize(400,400);
setTitle("Cirlce");
Oval o=new Oval();
add(o);
o.setBackground(Color.YELLOW);
}
public static void main(String[] args)
{
JFrame f=new Circle();
f.setVisible(true);
}
public class Oval extends JPanel
{
public void paintComponent(java.awt.Graphics g)
{
d=getSize();
System.out.println(d);
System.out.println(d.width/8);
System.out.println(d.height/8);
if(d.width>d.height)
g.fillOval(d.width/3,d.height/4,d.height/2,d.height/2);
else
g.fillOval(d.width/3,d.height/3,d.width/2,d.width/2);
}
}
}
No comments:
Post a Comment
Thank You !