好日子开发者:)
JavaFX组件TextArea是否支持某些事件,如onTextChange或类似事件?是的,我知道keyPressed,keyTyped ......但是如果另一个"action"在TextArea上做了更改,如何处理事件(例如.txArea.setText("some text")).
我在Windows 7和javafx上使用netbeans,当我运行程序时,此消息出现在输出中,
Warning:
The signer certificate will expire within six months.
Enter Passphrase for keystore: Enter key password for nb-jfx:
Signing JAR:
C:\Users\subhi\Desktop\SpeechRecognition\SpeechRecognition\dist\lib\batch.jar to
C:\Users\subhi\Desktop\SpeechRecognition\SpeechRecognition\dist\lib\batch.jar as nb-jfx
Run Code Online (Sandbox Code Playgroud)
有5个类似的消息,这些缓慢我的应用程序启动,我想禁用它们,我该怎么办?
我可以在javafx 2.1中使用eclipse吗?
我是JavaFX的新手,在我目前的设置下,我正在努力创建一个合适的MVC架构.我使用Scene Builder将UI单击在一起,并指定了一个Controller类.
启动:
public class Portal extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("PortalUI.fxml"));
stage.setTitle("Portal");
stage.setScene(new Scene(root));
stage.show();
}
}
Run Code Online (Sandbox Code Playgroud)
Controller类包含其余代码.
public class AccommodationPortalView implements Initializable {
@Override
public void initialize(URL url, ResourceBundle resources) {
// Work here.
}
}
Run Code Online (Sandbox Code Playgroud)
我的教授要求我进一步分离这个申请的关注点和责任.Controller不仅可以管理状态并与后端通信,还可以更新View.
我的第一个回应是让Controller类成为View并为Controller和Model创建另外两个类.
但是,我对如何连接这些部件感到茫然.我永远不需要实例化View,因此没有可以传递给我的Controller的View实例.接下来,我试着让它们成为所有单例,只是让Controller在运行时获取它们,但这给了我一个错误.
public class Portal extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception { …Run Code Online (Sandbox Code Playgroud) 根据文档,Region和Pane都会将任何可调整大小的子节点的大小调整为其首选大小,但不会重新定位它们.
所以我看不出这两个容器之间的差异在何处以及何时使用这些差异.
如何在TextArea中按Tab键导航到下一个控件?
我可以为cath de key按下事件添加一个监听器,但是如何让textArea控件失去焦点(不知道要聚焦的链中的下一个字段)?
@FXML protected void handleTabKeyTextArea(KeyEvent event) {
if (event.getCode() == KeyCode.TAB) {
...
}
}
Run Code Online (Sandbox Code Playgroud) 我需要创建具有多色行的JavaFx TableView(color1用于低优先级,color2用于中等优先级等).我创建了CellFactory
public class TaskCellFactory implements Callback<TableColumn, TableCell> {
@Override
public TableCell call(TableColumn p) {
TableCell cell = new TableCell<Task, Object>() {
@Override
public void updateItem(Object item, boolean empty) {
super.updateItem(item, empty);
setText(empty ? null : getString());
setGraphic(null);
TableRow currentRow = getTableRow();
Task currentTask = currentRow == null ? null : (Task)currentRow.getItem();
if(currentTask != null){
Priority priority = currentTask.getPriority();
clearPriorityStyle();
if(!isHover() && !isSelected() && !isFocused()){
setPriorityStyle(priority);
}
}
}
@Override
public void updateSelected(boolean upd){
super.updateSelected(upd);
System.out.println("is update");
}
private void …Run Code Online (Sandbox Code Playgroud) 我有一个ListView,想要以下内容:
那是我的代码.它的工作正常,除了偶数行:在鼠标悬停时,它以白色突出显示.所以,文字的白色并不能显示.它出什么问题了?
.list-cell:filled:selected:focused, .list-cell:filled:selected {
-fx-background-color: linear-gradient(#328BDB 0%, #207BCF 25%, #1973C9 75%, #0A65BF 100%);
-fx-text-fill: white;
}
.list-cell:odd {
-fx-cell-hover-color: #0093ff;
-fx-background-color: white;
}
.list-cell:filled:hover {
-fx-cell-hover-color: #0093ff;
-fx-text-fill: white;
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我有一个带文本字段和按钮的简单fxml.如果textfield为空,我想禁用该按钮.所以我在我的控制器中插入如下内容:
@Override
public void initialize(URL url, ResourceBundle bundle) {
button.disableProperty().bind(textField.textProperty().isEqualTo(""));
}
Run Code Online (Sandbox Code Playgroud)
..并且工作正常.问题是当我添加第二个文本字段并希望如果任一文本字段为空时我的按钮被禁用.该怎么办?我尝试了以下,但这不起作用:
@Override
public void initialize(URL url, ResourceBundle bundle) {
button.disableProperty().bind(textField.textProperty().isEqualTo(""));
button.disableProperty().bind(textField2.textProperty().isEqualTo(""));
}
Run Code Online (Sandbox Code Playgroud) 据我所知,当使用FXML描述Java FX场景时,手动编写控制器类,然后可以从.fxml文件中引用它的成员变量和方法.使用时加载场景FXMLLoader,成员变量设置为相应的场景元素,方法自动连接到相应的事件.这是有效的,但是非常麻烦,因为需要在两个地方进行更改,并且任何错误只会在运行时显示.
我见过其他GUI框架,它允许您从场景描述中生成控制器作为抽象类,需要实现它来访问场景元素并处理事件.我的意思的一个例子:
我将创建以下.fxml文件(例如,使用JavaFX Scene Builder):
<AnchorPane ... >
<children>
<Button fx:id="button" ... text="Button" onAction="#buttonPressed" />
</children>
</AnchorPane>
Run Code Online (Sandbox Code Playgroud)
在我的构建过程中的某个地方,.java将创建以下文件(例如,使用Maven插件):
abstract class TestController {
protected final Parent root;
protected final Button button;
{
// Load test.fxml file
// Assign scene elements to root and button
// Attach event handler to the button that calls buttonClicked()
}
protected abstract void buttonClicked(ActionEvent event);
}
Run Code Online (Sandbox Code Playgroud)
然后我可能会多次创建该控制器的具体实现:
final class …Run Code Online (Sandbox Code Playgroud) 我有下面的JQuery eventhandler.我想停止网页上的所有导航.
$(document).click(function(event) {
event.stopPropagation();
event.preventDefault();
event.cancelBubble = true;
event.stopImmediatePropagation();
$(document).css('border-color','');
$(document).css('background-color','');
$(event.target).css('border-color','yellow');
$(event.target).css('background-color','#6BFF70');
return false;
});
Run Code Online (Sandbox Code Playgroud)
当我在Facebook登录页面上使用它时,它会停止所有导航.但在谷歌主页上,"我感觉很幸运"按钮仍然导航到下一页.我该如何避免呢?
我顺便使用JavaFX浏览器.它类似于Safari浏览器.
javafx ×10
java ×5
javafx-2 ×3
architecture ×1
binding ×1
certificate ×1
components ×1
css ×1
fxml ×1
javascript ×1
jquery ×1
listview ×1
netbeans-7 ×1
tableview ×1
textarea ×1