Set Focus on FlowPane in Javafx


Question

i tried

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
         }
       }
     });

}

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?

1
0
1/11/2013 7:20:06 AM

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();
   }
});
2
5/17/2013 1:40:54 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon