Emergency!

Hi folks, i'm in a hurry
I'm writting kind of a game in java , my first. Everything went ok with the swing components (Y), but here is my problem, my consists on a robot who moves inside of an array. i do have a JPanel working with a GridBagLayout Manager to represent the array, then I use this panel as a component of a bigger panel together with some other components, that big panel is going to be the container of my JFrame.
    That's working good, but know y listen to the keyboard and receive a movement, (ok) i make the changes inside of the array (ok) but when i call to my paintarray method that first created the pane it seems to work ok , but I keep looking at the same thing , it does not refresh, i tried using container.repaint() panel.repaint() but doesn't work the code i use to PaintArray looks like :
public void Dibujar (JPanel pane, CCasilla[][] ma){
   int i, j;
   pane.removeAll();
   GridBagConstraints Rejillas = new GridBagConstraints();
   Rejillas.gridwidth=Rejillas.gridheight=1;
   for (i = 0 ; i < _fi; i ++){
           for ( j = 0 ; j <_co;j++){
         Rejillas.gridx = j;
         Rejillas.gridy = i;
         if (ma[j][i] == null){
            pane.add(new JLabel(cas),Rejillas);
         }
         else{
            pane.add(new JLabel(ma[j][i].getImagen()),Rejillas);
            if ((ma[j][i] instanceof CBeeper)||(ma[j][i] instanceof CRobot)){
                     pane.add(new JLabel(cas),Rejillas);
                                }
         }
           }
}
            
Need help !! how can I force my JFrame to show the changes in my Jpanel . And another question Im Using public class CGame extends JFrame implements KeyListener as the clase in which i listen the keyboard, i don't want to use the word implements ..... any other way ?? . ANYWAY the first question is the BIG ONE please HELP            
            
TheFredAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RuadRauFlessaCommented:
Have you tried looking at overriding the paint method and manually painting your sprite since it will be much faster and smoother and you can incorporate alot more from there.

If you still want to keep it like it is at the moment rather add a JLabel to every grid component and simply set and remove the icon's of the labels to ma[j][i].getImagen().

0
objectsCommented:
> how can I force my JFrame to show the changes in my Jpanel

pane.revalidate();

> And another question Im Using public class CGame extends JFrame implements KeyListener as the clase in which i listen
> the keyboard, i don't want to use the word implements ..... any other way ??

Use an inner class
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TheFredAuthor Commented:
objects, first one... worked fine thx, second one... how can i do that? When I compile this class "public class CGame extends JFrame implements KeyListener"  works fine when using sdk 1.3 but not as good when using 1.4 , the second one captures no keystroke. I think it's a problem of focus maybe to the frame ... how can i fix that?
0
objectsCommented:
you need to add your keylistener to whatever component has focus at the time you are interested.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.