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
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];
}
};
> 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