Run the test case below. Click on button two. This disables button two and three. However, the auto focus transfer from the disabling of button two causes focus to go to the also disabled button three, and it can't be moved with tab traversal.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ButTest extends JFrame {
private JButton one = new JButton("one");
private JButton two = new JButton("two");
private JButton three = new JButton("three");
private JButton four = new JButton("four");
public ButTest() {
super("ButTest");
setLayout(new FlowLayout());
add(one);
add(two);
add(three);
add(four);
two.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
two.setEnabled(false);
three.setEnabled(false);
}
});
}
private static void createAndShowGUI(String[] args) {
ButTest test = new ButTest();
test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test.setSize(400, 400);
test.setLocationRelativeTo(null);
test.setVisible(true);
}
public static void main(final String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI(args);
}
});
}
}