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

[تنبيه - عنوان غير مناسب : ]moveing the shape using transulat methode?

بدأه sara33 في 21 أبريل 2012 · 3 رد · 443 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليـــكم ...

كتبت هذا الكود ,,وفكرته :-

أرسم سياره وأضيف للإنترفيس 2buttons الأول forground والثاني backGround >>>

بحيث يكون الأكشن للبوتون الأول يحرك الرسمه من النقطه (0,0) الى (wedth,hight )

والثاني يحركها من (wedth,0 ) الى (0,hight )>>> كتبت الكود ولكن لم يتنفذ أي شيء ؟؟؟

وهذا الكـــود ..

public class JavaApplication88     extends JPanel{



    private JButton b=new JButton("Forward");
    private JButton b1=new JButton("Backward");


     public void paintComponent(Graphics g)
         {
        super.paintComponent(g);
        this.setBackground(Color.GRAY);
        g.setColor(Color.red);
       g.fillRoundRect(40, 40, 30, 10, 5, 5);
       // g.fill3DRect(40, 40,30, 10, true);
        g.setColor(Color.BLACK);
        g.fillOval(40, 45, 8, 8);
         g.fillOval(60, 45, 8, 8);
         g.setColor(Color.WHITE);
         g.fillArc(43, 35, 20, 15, 180, -180);


    }

public JavaApplication88()
    {



       b.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {

                     // how I can used methode transulate to move the car <<< I think the prameter of transulate methode is THE POINT OF WHEEL but 
                //I cant do this corectly <<<
                /* 
                    for(int i=0;i<wedth;i++)
                    * g.transulate(x,y);
                    * repaint();

                 */




            }
        });
        setLayout(new FlowLayout());
        add(b);
   add(b1);
    }



    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        JFrame frame=new JFrame("Move ");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(800,800);
       JavaApplication88 move=new  JavaApplication88();
         frame.add(move);
         frame.setVisible(true);
        // TODO code application logic here
    }
}

وشكــــراا ..

#2
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class JavaApplication88 extends JPanel {

	private JButton b = new JButton("Forward");
	private JButton b1 = new JButton("Backward");
	int x = 40, y = 80;

	public void paintComponent(Graphics g) {
    	super.paintComponent(g);
    	this.setBackground(Color.GRAY);
    	g.setColor(Color.red);
    	g.fillRoundRect(x, y, 30, 10, 5, 5);
    	g.setColor(Color.BLACK);
    	g.fillOval(x, y + 5, 8, 8);
    	g.fillOval(x + 20, y + 5, 8, 8);
    	g.setColor(Color.WHITE);
    	g.fillArc(x + 3, y - 5, 20, 15, 180, -180);
	}

	public JavaApplication88() {

    	b.addActionListener(new ActionListener() {

        	public void actionPerformed(ActionEvent e) {
            	x += 10;
            	if (x >= getWidth() - 30) {
                	x = getWidth() - 30;
            	}
            	repaint();
        	}
    	});
    	b1.addActionListener(new ActionListener() {

        	public void actionPerformed(ActionEvent e) {
            	x -= 10;
            	if (x < 0) {
                	x = 0;
            	}
            	repaint();
        	}
    	});
    	setLayout(new FlowLayout());
    	add(b);
    	add(b1);
	}

	/**
 	* @param args the command line arguments
 	*/
	public static void main(String[] args) {
    	JFrame frame = new JFrame("Move ");
    	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	frame.setSize(800, 800);
    	frame.setLocationRelativeTo(null);
    	JavaApplication88 move = new JavaApplication88();
    	frame.add(move);
    	frame.setVisible(true);
	}
}

Software Developer
Mahmoudkelany.com


 

#3

رب يجــزاك خير ..ويفتــح عليك ويزيدك من فضله

#4

الأخ الكريم/الأخت الكريمة

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

مرحباً بكم في منتدى الفريق العربي للبرمجة

نود تنبيهك أن العنوان غير مناسب.

الرجاء اختيار عنوان مناسب أكثر في مواضيعك القادمة، وهذا بمثابة إشعار للأهمية.

وفي حال التكرار سيتعرض موضوعك للإغلاق والحذف!!!

قواعد المشاركة

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

حزمة المحرك الإصدارة 0.8

أي أحد يجد أني ظلمته فليراسلني

وبإذن الله لو كان له حق سيأخذه

728x90.png

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