Troubleshooting focussing problem.

I am having many componets onthe Panel(acutully inside many panels). i just want to pass the focus from one JTextArea to another JTextArea. I gave the code to work accordingly. but something getting focus in the middle. I want to just troubleshoot it.

can anyone give a clue.

Thanks

[302 byte] By [umamittapallia] at [2007-10-2 5:20:06]
# 1
You should use java.awt.FocusTraversalPolicy
genga at 2007-7-16 1:22:10 > top of Java-index,Desktop,Core GUI APIs...
# 2
Mixing AWT component (Panel) with Swing component (JTextArea) might produce some strange behavior.
ajneoa at 2007-7-16 1:22:10 > top of Java-index,Desktop,Core GUI APIs...
# 3
Sorry... Thats absolutely JPanel. mistaken.
umamittapallia at 2007-7-16 1:22:10 > top of Java-index,Desktop,Core GUI APIs...
# 4
If you could post an example of the code you're using, explain what you're expecting to happen and what's actually happening that would be useful.Remember to put your code in [ code ] tags!
KPSeala at 2007-7-16 1:22:10 > top of Java-index,Desktop,Core GUI APIs...
# 5

i am using the following code for FocusTraversalPolicy. The problem is that i am using txtCmd and txtServerLists are TextAreas. Though i apply i didnot succed. in both TextAreas and another JTablePanes are used JScrollPanes.

final Component order[] =

new Component[] {txtCmd,txtServerList,clear,start};

FocusTraversalPolicy policy = new FocusTraversalPolicy() {

List list = Arrays.asList(order);

public Component getFirstComponent(Container focusCycleRoot) {

return order[0];

}

public Component getLastComponent(Container focusCycleRoot) {

return order[order.length-1];

}

public Component getComponentAfter(Container focusCycleRoot,

Component aComponent) {

int index = list.indexOf(aComponent);

return order[(index + 1) % order.length];

}

public Component getComponentBefore(Container focusCycleRoot,

Component aComponent) {

int index = list.indexOf(aComponent);

return order[(index - 1 + order.length) % order.length];

}

public Component getDefaultComponent(Container focusCycleRoot) {

return order[0];

}

};

umamittapallia at 2007-7-16 1:22:10 > top of Java-index,Desktop,Core GUI APIs...
# 6
yeah...i can move from txtServerList to clear button without any problem with just TAB key . but txtCmd to txtServerList i need to press two TAB key to move. why is like this?
umamittapallia at 2007-7-16 1:22:10 > top of Java-index,Desktop,Core GUI APIs...
# 7
Component compFocusOwner =KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();helped me to traceroute.
umamittapallia at 2007-7-16 1:22:10 > top of Java-index,Desktop,Core GUI APIs...
# 8

> need to press two TAB key to move. why is like this?

The first tab places focus on the scrollbar, and the second tab moves you to the next component.

Here are some different ways to tab out of a JTextArea:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=609727

camickra at 2007-7-16 1:22:10 > top of Java-index,Desktop,Core GUI APIs...