Home » » DrawTest in Java Program

DrawTest in Java Program

DrawTest in Java Program

DrawTest in Java Program

DrawTest in Java Program

import java.awt.*;
import jacva.awt.geom.*;
import javax.Swing.*;
public class DrawTest
{
public Static void main(String args[])
{
JFrame frame=new JFrame("2D shapes");
Container contentPane=frame.getcontentPane();
contentPane.add(new DrawPanel());
frame.setSize(200,200);
frame.setLocation(100,200);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
class DrawPanel extends JPanel
{
public void paintcomponent(Graphics g)
{
super.paintcomponent(g);
setBackground(color.darkGray);
Graphics2D g2=(Graphics 2D)g;
double leftX=40;
double topY=40;
double width=80;
double height=60;
Rectangle2D rect=new Rectangle2D.Double(leftX,topY,width,height);
g2.setPaint(color.gray);
g2.fill(rect);
}

}

0 coment�rios:

Post a Comment

Link you don't want to vouch for Read more: https://html.com/seo/#ixzz5zVltiZ5g