ENTER key using in JTextField java

一个人想着一个人 提交于 2019-11-28 13:53:45
camickr

Add an ActionListener to the first text field. In the ActionEvent you can get the source object, cast it to a JTextField and then invoke the transferFocus() method.

Use actionListener for the textField.

Code snippet:

textField1.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
        textField1.transferFocus();
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!