简体   繁体   中英

Java - Change behavior Tab key

i have simple gui app and, when I press Tab key, it move focus like this:

IMG

but i wanna move like this:

IMG

public class Test extends javax.swing.JFrame {

    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;   

    public Test() {
        initComponents();
    }

    // NetBeans generate Form code

    public static void main(String args[]) {
        new Test().setVisible(true);
    }

}

you need a custom FocusTraversalPolicy. see here for an example -> Example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM