我想从我的控制器类处理阶段事件(即隐藏).所以我要做的就是通过添加一个监听器
((Stage)myPane.getScene().getWindow()).setOn*whatIwant*(...);
Run Code Online (Sandbox Code Playgroud)
但问题是初始化刚刚开始
Parent root = FXMLLoader.load(getClass().getResource("MyGui.fxml"));
Run Code Online (Sandbox Code Playgroud)
之前
Scene scene = new Scene(root);
stage.setScene(scene);
Run Code Online (Sandbox Code Playgroud)
因此.getScene()返回null.
我自己找到的唯一解决方法是向myPane.sceneProperty()添加一个监听器,当它变为非null时,我得到场景,添加到它的.windowProperty()我的!该死!我最终检索阶段的监听器处理.这一切都以设置所需的听众来举办舞台活动而告终.我认为听众太多了.这是解决我问题的唯一方法吗?
在我的应用程序中,我使用两个Tabs.在第一个我放置HtmlEditor,在第二个我放置TextArea.HTML选项卡是默认的,当用户创建HTML输入时,他可以切换到TextArea以直接查看/更改HTML源代码.我添加了一个监听器来从HtmlEditor获取rhe htmlText并将其设置为TextArea中的文本,因此用户可以轻松地在HTML和源模式之间切换.这是我的倾听者:
@FXML
private Tab htmlTab;
@FXML
private Tab sourceTab;
@FXML
private HTMLEditor htmlEditor;
@FXML
private TextArea textEditor;
htmlTab.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if (htmlTab.isSelected()) {
htmlEditor.setHtmlText(textEditor.getText());
}
}
});
sourceTab.selectedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if (sourceTab.isSelected()) {
textEditor.setText(htmlEditor.getHtmlText());
}
}
});
Run Code Online (Sandbox Code Playgroud)
它工作正常,但HtmlEditor自动将文本分成行.当我切换到TextArea时,它都在一行中.
我想过制作一个辅助方法,它采用TextArea长度属性来计算字符数,并在每个"n"字符中添加新的行字符,但也许有更好的解决方案?
我想在 ionic 3 中进行批量插入我有这个代码它可以工作但它真的很慢
insertQuotation(value){
for(var i=0; i<=value.length; i++){
let data=[value[i].quotation_id,value[i].customer_name,value[i].product_name,value[i].price,value[i].services,value[i].response_time,value[i].created_time];
this.database.executeSql("insert into care_plan_quotation_history(care_plan_quotation_id,customer_name,product,price,services,response_time,created_time) values(?,?,?,?,?,?,?)",data)
.then(data=>{
return data;
},err=>{
alert("error");
})
}
}
Run Code Online (Sandbox Code Playgroud)
请在这件事上给予我帮助
我目前正在尝试将 DatePicker 的可编辑设置为 false,因此无法更改该值。使用以下仅禁用文本字段,但仍允许通过单击日历按钮更改日期(setEditable 用于权限,因此我可以根据登录情况启用/禁用):
exampleDatePicker.setEditable(user.getGroup().equals(admin));
Run Code Online (Sandbox Code Playgroud)
有没有办法禁用 DatePicker 上的日历按钮?我不想使用 setDisable,因为我仍然希望该字段是可读的,而且我无法更改禁用的 CSS,因为我有其他禁用的 DatePicker,我希望它们变灰。