:) مرحباااااااااا
اتمنى اني الاقي عندكم الاجابه
ابي ارسم دائره بالجافا بس تكون فاضيه (مش ملونه
كييييييييييييييييييف؟؟؟؟
اتريا ردودكم بلييييييز
:) مرحباااااااااا
اتمنى اني الاقي عندكم الاجابه
ابي ارسم دائره بالجافا بس تكون فاضيه (مش ملونه
كييييييييييييييييييف؟؟؟؟
اتريا ردودكم بلييييييز
import javax.swing.*;
import java.awt.*;
/** Drawing example. **/
public class SimpleDraw2Applet extends JApplet
{
public void init () {
Container content_pane = getContentPane ();
Math.random ();
// Get the drawing area of the applet
int dY = getSize ().height;
int dX = getSize ().width;
// Create a random number of circles up to 3
int numCircles = (int) (2.0 * Math.random () + 1.0);
// Create a circle array
Circle [] circs = new Circle[numCircles];
// Now create the circle instances
for (int i=0; i < numCircles; i++) {
circs = new Circle (dX,dY);
}
// Create an instance of DrawingPanel
DrawingPanel drawing_panel = new DrawingPanel (circs);
// Add the DrawingPanel to the contentPane.
content_pane.add (drawing_panel);
} // init
} // class SimpleDraw2Applet
class DrawingPanel extends JPanel
{
Circle [] fCircles;
int fNumCircles;
DrawingPanel (Circle [] circles) {
fCircles = circles;
fNumCircles = circles.length;
} // ctor
public void paintComponent (Graphics g) {
// First paint background
super.paintComponent (g);
// Add your drawing instructions here
g.setColor (Color.red);
// Draw the circles
for ( int i=0; i < fNumCircles; i++){
g.fillOval (fCircles.fX,fCircles.fY,
fCircles.fDx,fCircles.fDy);
}
} // paintComponent
} // class DrawingPanel
/** Circle class definition. **/
class Circle
{
// These attributes provide the position &
// dimensions of the circle and a box that
// bounds it.
int fCenterX,fCenterY;
int fRadius;
int fX,fY;
int fDx,fDy;
// Use constructor to
Circle (int x_axis_width, int y_axis_height) {
// Fix circles at 20% of horizontal axis
fRadius = (int) (0.1 * x_axis_width);
// choose random center location
fCenterX = (int) ((x_axis_width) * Math.random ());
fCenterY = (int) ((y_axis_height) * Math.random ());
// Now calculate the bounding rectangle
fX = fCenterX - fRadius;
fY = fCenterY - fRadius;
fDx = 2 * fRadius;
fDy = 2 * fRadius;
// Move away from edges.
if (fX < 0) {
fX = -fX;
fCenterX += 2 * fX;
} else if ((fX+fDx) > x_axis_width) {
fX -= 2 * fDx;
fCenterX -= 2 * fDx;
} if (fY < 0) {
fY = -fY;
fCenterY += 2 * fY;
} else if ((fY+fDy) > y_axis_height) {
fY -= 2 * fDy;
fCenterY -= 2 * fDy;
}
} // ctor
} // class Circleتم تعديل هذه المشاركة بواسطة yadoo86 في 13 أبريل 2007 في 22:31


thhaaaaaaaanx
بس انا ابيها فاضيه مش ملونه
وشكرا
هذا الموضوع مغلق.