在Javafx中将焦点放在FlowPane上 [英] Set Focus on FlowPane in Javafx

查看:615
本文介绍了在Javafx中将焦点放在FlowPane上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过

public void ChangeFocus(Button browse, final FlowPane mFlowPane)
{
    browse.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {

         @Override
         public void handle(KeyEvent event)
         {
             if (event.getCode() == KeyCode.TAB)
             {
                System.out.println("TAB pressed");
                mFlowPane.requestFocus();
                event.consume(); // do nothing
         }
       }
     });

}

在上面的代码中我在Flowpane中设置了一个ImageView但是当我按我的浏览按钮上的TAB按钮我无法专注于imageview如何解决它?

in above code i set one ImageView inside Flowpane but when i press TAB button on my browse button i can't get focus on imageview how can i solve it?

推荐答案

更多细节到解决这个问题。而不是关注flowpane你需要把焦点放在flowpane中的什么,例如textfield:

some more detail to solve it. instead of focusing the flowpane you need to set the focus on whats in the flowpane, for example a textfield:

flowPane.setOnMouseClicked(new EventHandler<MouseEvent>()
{
   public void handle(MouseEvent mouseEvent)
   {
         textfield.requestFocus();
   }
});

这篇关于在Javafx中将焦点放在FlowPane上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆