how to darw a point in the middle :
أريد أن أرسم نقطة دائريه في وسط الصفحه عن طريق استخدام برنامج
blue j
قمت بعمل كود لرسم النقطة و لكن لم استطع أن أرسمه في الوسط .. فكيف أستطيع أن أجعل هذه النقطةترسم في الوسط
و ما اخطأ في هذا الكووود ..
import java.awt.*;
import java.awt.geom.*;
/**
* A point that can be manipulated and that draws itself on a canvas.
* @author Michael Kolling and David J. Barnes
* Modified by:
*/
public class Point
{
private int diameter;
private int xPosition;
private int yPosition;
private String color;
private boolean isVisible;
/**
* Create a new circle at default position with default color.
*/
public Point(int x, int y)
{
diameter = 4;
xPosition = x;
yPosition = 300-y;
color = "=blue";
makeVisible() ;
}
public void setXPosition (int x)
{
xPosition = x;
}
public void setYPosition (int y)
{
yPosition = y;
}
public int getXPosition (){
return xPosition;
}
public int getYPosition (){
return yPosition;
}
/**
* Make this circle visible. If it was already visible, do nothing.
*/
public void makeVisible()
{
isVisible = true;
draw();
}
/**
* Change the color. Valid colors are "red", "yellow", "blue", "green",
* "magenta" and "black".
*/
public void SetColor(String newColor)
{
color = newColor;
draw();
}
/*
* Draw the circle with current specifications on screen.
*/
private void draw()
{
if(isVisible) {
Canvas canvas = Canvas.getCanvas();
canvas.draw(this, color, new Ellipse2D.Double(xPosition, yPosition,
diameter, diameter));
canvas.wait(10);
}
}
/*
* Erase the circle on screen.
*/
private void erase()
{
if(isVisible) {
Canvas canvas = Canvas.getCanvas();
canvas.erase(this);
}
}
public void PrintData()
{
System.out.println("################# ");
System.out.println(" Point color " + color);
System.out.println(" Point diameter " + diameter);
System.out.println(" Point X Position " + xPosition);
System.out.println(" point Y Position " + yPosition);
System.out.println("################# ");
}
}
أرجووو الإفادة
أختكم :wub:
