الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

أرجوا المساعده بسرررررعه

مغلق
بدأه همة متفائلة في 24 مايو 2007 · 3 رد · 571 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

أخواني أريد المساعدة في فهم هذا البرنامج

// Fig. 12.23: Shapes2.java

// Demonstrating a general path

.

import java.awt.*; import java.awt.geom.*; import javax.swing.*;

public class Shapes2 extends JFrame {

// set window's title bar String, background color and dimensions

public Shapes2()

{

super( "Drawing 2D Shapes" );

getContentPane().setBackground( Color.WHITE );

setSize( 400, 400 );

setVisible( true );

}

// draw general paths

public void paint( Graphics g )

{ super.paint( g ); // call superclass's paint method

int xPoints[] = { 55, 67, 109, 73, 83, 55, 27, 37, 1, 43 };

int yPoints[] = { 0, 36, 36, 54, 96, 72, 96, 54, 36, 36 };

Graphics2D g2d = ( Graphics2D ) g;

GeneralPath star = new GeneralPath(); // create GeneralPath object

// set the initial coordinate of the General Path

star.moveTo( xPoints[ 0 ], yPoints[ 0 ] );

// create the star--this does not draw the star

for ( int count = 1; count < xPoints.length; count++ )

star.lineTo( xPoints[ count ], yPoints[ count ] );

star.closePath(); // close the shape

g2d.translate( 200, 200 ); // translate the origin to (200, 200)

// rotate around origin and draw stars in random colors

for ( int count = 1; count <= 20; count++ ) {

g2d.rotate( Math.PI / 10.0 ); // rotate coordinate system

// set random drawing color

g2d.setColor( new Color( ( int ) ( Math.random() * 256 ),

( int ) ( Math.random() * 256 ),

( int ) ( Math.random() * 256 ) ) );

g2d.fill( star ); // draw filled star }

جزاكم الله خيرا

قال ابن القيم رحمه الله ( إن دور الجنة تبنى بالذكر فإذا أمسك الذاكر عن الذكر أمسكت الملائكة عن البناء )

سبحان الله وبحمده سبحان الله العظيم

#2

أعقد أنك حصلت عليه من deitel ؟

ستجد الشرح هناك :P

#3

جزاك الله خيرا

أخذته من شرائح

powerpoint

لا يوجد فيها شرح

قال ابن القيم رحمه الله ( إن دور الجنة تبنى بالذكر فإذا أمسك الذاكر عن الذكر أمسكت الملائكة عن البناء )

سبحان الله وبحمده سبحان الله العظيم

#4

استخدم الcode tag ياأخي

الشئ الآخر عدلت على الكود حتى يشتغل :

// Fig. 12.23: Shapes2.java
// Demonstrating a general path


import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.*;
import javax.swing.*;
class Shapes2 extends JFrame {
	public static void main(String[] args){
	   Shapes2 sh= new Shapes2();
	   sh.addWindowListener(new WindowAdapter(){
		   public void windowClosing(WindowEvent we) {
			 System.out.println("Bye Bye");
			 System.exit(0);
			  }
	   });
	}
// set window's title bar String, background color and dimensions
public Shapes2()
{
super( "Drawing 2D Shapes" );
getContentPane().setBackground( Color.WHITE );
setSize( 400, 400 );
setVisible( true );
}
// draw general paths

public void paint( Graphics g )
{ super.paint( g ); // call superclass's paint method
int xPoints[] = { 55, 67, 109, 73, 83, 55, 27, 37, 1, 43 };
int yPoints[] = { 0, 36, 36, 54, 96, 72, 96, 54, 36, 36 };

Graphics2D g2d = ( Graphics2D ) g;
GeneralPath star = new GeneralPath(); // create GeneralPath object
// set the initial coordinate of the General Path
star.moveTo( xPoints[ 0 ], yPoints[ 0 ] );
// create the star--this does not draw the star
for ( int count = 1; count < xPoints.length; count++ )
star.lineTo( xPoints[ count ], yPoints[ count ] );
star.closePath(); // close the shape
g2d.translate( 200, 200 ); // translate the origin to (200, 200)
// rotate around origin and draw stars in random colors
for ( int count = 1; count <= 20; count++ ) {
g2d.rotate( Math.PI / 10.0 ); // rotate coordinate system
// set random drawing color
g2d.setColor( new Color( ( int ) ( Math.random() * 256 ),( int ) ( Math.random() * 256 ),( int ) ( Math.random() * 256 ) ) );
g2d.fill( star ); // draw filled star 
}

}}

بالنسبه للشرح المسأله بسيطه ، إقرأ الـdocumentation حق الكلاسات اللي استخدمها ببرنامجك Graphics2D , GeneralPath

http://java.sun.com/javase/6/docs/api/

اذا فيه سؤال محدد تفضل ...

هذا الموضوع مغلق.

مواضيع مشابهة