JButton.grabFocus();
我可查了半天的 API 啊

解决方案 »

  1.   

    可以在JButton的action事件的actionPerformed方法中用jButton.requestFocus();不就可以了吗,这样就能实现你的想法了。
      

  2.   

    jbutton1.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            jbutton2.requestFocus();
        }
    }
      

  3.   

    楼上讲得也对
    我试过了
    JButton.grabFocus();
    jbutton2.requestFocus();
    两者都可行
    可是有什么区别吗?
      

  4.   

    javax.swing 
    Class JComponentgrabFocus
    public void grabFocus()
    Sets the focus on the receiving component if it doesn't already have it. This method is for focus managers. You rarely want to call this method; use requestFocus() instead.requestFocus
    public void requestFocus()Sets focus on the receiving component if isRequestFocusEnabled returns true and the component doesn't already have focus.
    Overrides:
    requestFocus in class Component
    Following copied from class: java.awt.Component 
      

  5.   

    看来还是用
    requestFocus();
    比较好