Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to stop a parent from getting the focus from child.requestFocus()?

KonradZuseMay 15 2013 — edited May 23 2013
So I have this code
class mouseHandler implements EventHandler<MouseEvent>
{
 
    private double sceneAnchorX;
    private double sceneAnchorY;
    private double anchorAngle;
    private Parent parent;
 
    private final Node nodeToMove ;
 
    mouseHandler(Node nodeToMove) 
    {
       this.nodeToMove = nodeToMove ;

    } 
 
    @Override
    public void handle(MouseEvent event)
    {
 
      else if(event.getEventType() == MouseEvent.MOUSE_CLICKED)
      {
          nodeToMove.requestFocus();
      }
      
                     nodeToMove.setOnKeyPressed((KeyEvent)
 ->{
     if(KeyCode.UP.equals(KeyEvent.getCode()))
     {
         nodeToMove.setScaleX(nodeToMove.getScaleX()+ .1);
         nodeToMove.setScaleY(nodeToMove.getScaleY()+ .1);
         nodeToMove.setScaleZ(nodeToMove.getScaleZ()+ .1);
         System.out.println("kaw");
     }
     
     
     if(KeyCode.DOWN.equals(KeyEvent.getCode()))
     {
         nodeToMove.setScaleX(nodeToMove.getScaleX()- .1);
         nodeToMove.setScaleY(nodeToMove.getScaleY()- .1);
         nodeToMove.setScaleZ(nodeToMove.getScaleZ()- .1);
         System.out.println("kaw");
     }
 });
    }
}
requestFocus()
Requests that this Node get the input focus, and that this Node's top-level ancestor become the focused window.
I don't want the top level to be focused, I want my child to be. Basically I have a class that extends group and that is the node I want focus on. Instead the focus goes to the root group.

Edited by: KonradZuse on May 19, 2013 7:57 PM

Edited by: KonradZuse on May 21, 2013 9:28 PM
This post has been answered by James_D on May 23 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 20 2013
Added on May 15 2013
10 comments
310 views