May 4, 2003 4

Swing requestFocus blues part II

By in Java

hmm – i probably didn’t explain my problem very well the last time – or at least not to the point.
But I got one answer though.

“Just catch component shown event and then request focus ” – Krage Termini

Well, this is ok and solves the problem of “when this panel is first shown which component should get the focus”-problem.

The other problem of just being able to say somepanel.requestFocus() instead of somepanel.getAField().requestFocus() (which breaks encapsulation) is not solved by this one.

Maybe one should just override .requestFocus() on the “somepanel” which delegates the call to the “first field” ? hmm – is that the correct way ? It sounds “messy” to be forced to inherit from JPanel to encapsulate it’s focus mechanism….

  • http://bgp400786bgs.jersyc01.nj.comcast.net KT

    Just add an inner class – listener of shown event inside your "somepanel" to transfer focus to the disired private field.

  • http://clt56-97-164.carolina.rr.com LES

    Create a nice little anonymous override of the focus event handler for the JPanel (though a type would be better if you want reuse). Then all you have to do is catch the component shown and send a focus event to the panel. The panel would then know what to do with the focus event.

  • http://adsl-68-125-183-249.dsl.irvnca.pacbell.net free casino online

    A bad cause will ever be supported by bad means and bad men. by <a href="http://www.free-casino-game… title="roulette">roulette</a>

  • http://dns.mega.com.pl free poker online

    No evil can happen to a good man, either in life or after death. by <a href="http://www.poker-rooms-777…. title="free online poker">free online poker</a>

canlı sohbet hattı telefonda sex telefonda seks sex erotik sohbet hattı sex sex sex sikiş porno porno porno porno izle