السلام عليـــكم ...
كتبت هذا الكود ,,وفكرته :-
أرسم سياره وأضيف للإنترفيس 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
}
}وشكــــراا ..
