Fix small issues in traversal policy
This commit is contained in:
parent
5e4ef37048
commit
6be54e1d48
@ -43,7 +43,7 @@ public class CustomFocusTraversalPolicy extends FocusTraversalPolicy {
|
|||||||
idx = order.size() - 1;
|
idx = order.size() - 1;
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (!order.get(idx).isEnabled()) {
|
while (!order.get(idx).isEnabled() || !order.get(idx).isShowing() || !order.get(idx).isVisible()) {
|
||||||
idx = (idx - 1) % order.size();
|
idx = (idx - 1) % order.size();
|
||||||
count++;
|
count++;
|
||||||
if (count == order.size())
|
if (count == order.size())
|
||||||
@ -53,14 +53,22 @@ public class CustomFocusTraversalPolicy extends FocusTraversalPolicy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Component getDefaultComponent(Container focusCycleRoot) {
|
public Component getDefaultComponent(Container focusCycleRoot) {
|
||||||
return order.get(0);
|
return getFirstComponent(focusCycleRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getLastComponent(Container focusCycleRoot) {
|
public Component getLastComponent(Container focusCycleRoot) {
|
||||||
return order.get(order.size() - 1);
|
int idx = order.size() - 1;
|
||||||
|
if ((order.get(idx).isEnabled() && order.get(idx).isShowing() && order.get(idx).isVisible())) {
|
||||||
|
return order.get(idx);
|
||||||
|
}
|
||||||
|
return getComponentBefore(focusCycleRoot, order.get(idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getFirstComponent(Container focusCycleRoot) {
|
public Component getFirstComponent(Container focusCycleRoot) {
|
||||||
return order.get(0);
|
int idx = 0;
|
||||||
|
if ((order.get(idx).isEnabled() && order.get(idx).isShowing() && order.get(idx).isVisible())) {
|
||||||
|
return order.get(idx);
|
||||||
|
}
|
||||||
|
return getComponentAfter(focusCycleRoot, order.get(idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user