非常に単純な GUI プログラムを VB6 から Java に変換中です。使用する一部のコンポーネント (ProgressBar、Label、Buttons など) には、特定のタブ オーダーが必要です。言うまでもなく、VB6 で特定のタブ オーダーを割り当てる方がはるかに簡単です (ただし、指を指しているわけではありません)。
オラクルがこれを行う方法についてのドキュメントをここに持っていることは認識していますが、上記の例ほどプログラミングすることなく、前述の問題を解決する簡単な方法があることを望んでいました.
ありがとう
編集 - これは、私が話している上記のリンクからのプログラムの特定のセクションです。
Vector<Component> order = new Vector<Component>(7);
order.add(tf1);
order.add(tf2);
order.add(tf3);
order.add(tf4);
order.add(tf5);
order.add(tf6);
order.add(table);
newPolicy = new MyOwnFocusTraversalPolicy(order);
...
public void actionPerformed(ActionEvent e) {
if ("toggle".equals(e.getActionCommand())) {
frame.setFocusTraversalPolicy(togglePolicy.isSelected() ?
newPolicy : null);
}
}
...
public static class MyOwnFocusTraversalPolicy
extends FocusTraversalPolicy
{
Vector<Component> order;
public MyOwnFocusTraversalPolicy(Vector<Component> order) {
this.order = new Vector<Component>(order.size());
this.order.addAll(order);
}
public Component getComponentAfter(Container focusCycleRoot,
Component aComponent)
{
int idx = (order.indexOf(aComponent) + 1) % order.size();
return order.get(idx);
}
public Component getComponentBefore(Container focusCycleRoot,
Component aComponent)
{
int idx = order.indexOf(aComponent) - 1;
if (idx < 0) {
idx = order.size() - 1;
}
return order.get(idx);
}
public Component getDefaultComponent(Container focusCycleRoot) {
return order.get(0);
}
public Component getLastComponent(Container focusCycleRoot) {
return order.lastElement();
}
public Component getFirstComponent(Container focusCycleRoot) {
return order.get(0);
}
}