requestFocus() not working with show() method

I'm making a game where the program has to show one panel, and from that panel show the previous panel, and then show the first panel again. To make things simpler, let's say we have PanelA and PanelB in a CardLayout c of panelc. The program starts with c.show(panelc, "PanelB"); panelb.requestFocus();. Then, in PanelB, this happens: c.show(panelc, "PanelA"). Then, in PanelA, the same thing happens again: c.show(panelc, "PanelB"); panelb.requestFocus();

The first time around, the requestFocus() works perfectly with my KeyListener and the game works fine. But the second time around when panelb is shown, it seems the requestFocus does not work and KeyListener does not respond to any events.

Answers


Need Your Help

how do you remember a checkbox in a cookie.

javascript cookies

i want to know how to remember a check box value in a cookie i have method createCookie.

VB.Net - Toolstrip Button Mousehover Event

vb.net toolstrip

Is there a way to change the size of the toolstrip button on mousehover event?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.