Node Class 的requestFocus方法

如果想为某个UI控件设置获得焦点时,使用requestFocus方法。

但调用该方法时必须注意一点:其父节点对象必须具有获得焦点的能力,父节点的父节点也必须一样,美国空间,网站空间,以此类推,直到顶级Scene,香港服务器租用,例如:

View Code

1RadioButton groupRadioButton1=new RadioButton(“GroupRadioButton1”); 2groupRadioButton1.setLayoutX(0); 3groupRadioButton1.setLayoutX(0); 4RadioButton groupRadioButton2=new RadioButton(“GroupRadioButton2”); 5groupRadioButton2.setLayoutX(20); 6groupRadioButton2.setLayoutY(20); 7RadioButton groupRadioButton3=new RadioButton(“GroupRadioButton3”); 8groupRadioButton3.setLayoutX(40); 9groupRadioButton3.setLayoutY(40);10final ToggleGroup toggleGroup =new ToggleGroup();11 groupRadioButton1.setToggleGroup(toggleGroup);12 groupRadioButton2.setToggleGroup(toggleGroup);13 groupRadioButton3.setToggleGroup(toggleGroup);14 Group group=new Group();15 group.getChildren().addAll(groupRadioButton1,groupRadioButton2,groupRadioButton3);16 Scene scene = new Scene(group, 600, 400);17 groupRadioButton2.requestFocus();人生如果错了方向,停止就是进步”。

Node Class 的requestFocus方法

相关文章:

你感兴趣的文章:

标签云: