08. december 2008 - 22:00Der er
3 kommentarer og 1 løsning
How to find out if a tab got Focus?
Hello!
I'm playing around with a JTabbedPane and I need to find out which tab that got focus.
I have tried like this with a state listener:
public void stateChanged(ChangeEvent e) { if(e.getSource() == tabbedPane) { Component[] components = tabbedPane.getComponents(); for(int i = 0; i < components.length; i++) { if(components[i].hasFocus()) { System.out.println("HELLO GOT FOCUS") } } ...
But it seem not to work.
So if you guys know any nice startegy for this please let me know. And if you also can explain why my idea did not work that would be most welcome as well.
Thanks for your replies! Your solution worked perfect welcor.
Yes I'm from sweden, not so far away. But I must say that some times it is easier to communicate in english, but I acctually have increased my knowledge in Danish alot since I have become a member at eksperten.dk.
I guess that if I tried to post in swedish there would be alot of funny missunderstanding. Do you by the way got this strange "way of speak" in Denmark: Swedish - Kan du kasta ett getöga på det här? Direct into english - Could you throw an eye of a goat on this? Means - Could you take a quick glance on this issue?
Pretty strange and a bit funny I must say ;-) I have decided that I will try not to torture you with swedish then ;-)
At my former job we also had alot of employees from foreign countries. Then it helped alot when I could show them all the help I have got from eksperten.dk, mainly from you Arne. And in my opinion I must say that eksperten.dk had not met its match any where on the Internet. I also recomend eksperten.dk to every one that's ask for a good IT-forum.
Also I always need to practice my english so I hope you guys not mind.
Thanks to you both and see you around!
Best regards Fredrik
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.