javafx-2

Interacting with the controls of a JavaFX application from a foreign language (Prolog) by means of JNI

大憨熊 提交于 2019-12-24 00:33:56
问题 I would like to interact (as transparently as possible from the Java point of view) with the controls of a JavaFX application from an application in a foreign language (Prolog). Java and Prolog are connected by means of JNI and I have already resolved the JNI interaction issues. My question is: What is the best way to instrument an arbitrary JavaFX application so I could inject code somewhere to invoke a routine in Prolog immediately after the primary Stage has been instantiated ? (so Prolog

Replace Text with number in TextField

和自甴很熟 提交于 2019-12-24 00:12:15
问题 I have this field in which I insert port number. I would like to convert the string automatically into number: fieldNport = new TextField(); fieldNport.setPrefSize(180, 24); fieldNport.setFont(Font.font("Tahoma", 11)); grid.add(fieldNport, 1, 1); Can you tell how I can do this? I cannot find suitable example in stack overflow. EDIT: Maybe this: fieldNport.textProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue o, Object oldVal, Object newVal) { try {

FXML, script tag and initialize method

限于喜欢 提交于 2019-12-23 22:59:47
问题 I am testing and discovering JavaFX. In JavaFX FXML documentation about controllers, it is said that if the controller has a public void initialize() method, it is called once the FXML graph is loaded. Is it possible to do something similar, but from the FXML file in a script way? I tried something like that, but initialize() is not called at all. <?xml version="1.0" encoding="UTF-8"?> <?language javascript?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.AnchorPane?>

shaking Stage in javaFX

做~自己de王妃 提交于 2019-12-23 20:15:22
问题 is it possible to shake primary stage with Timeline and so Use XTimeline and YTimeLine? final Timeline Xtimeline = new Timeline();//for Animate On X'-Stage Xtimeline.setCycleCount(Timeline.INDEFINITE); Xtimeline.setAutoReverse(true); final Timeline Ytimeline = new Timeline();//for Animate On Y'-Stage Ytimeline.setCycleCount(Timeline.INDEFINITE); Ytimeline.setAutoReverse(true); 回答1: Try This.. int x = 0; int y = 0; public void shakeStage() { Timeline timelineX = new Timeline(new KeyFrame

Combine multiple jar into one (using maven)

孤者浪人 提交于 2019-12-23 19:44:55
问题 I have a project in javafx , I have 3 dependencies I try to combine them with my principale jar using maven : The result I got a jar (1.82mb) but when I click he dosen't launch noting appears. pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <dependencies>

JavaFX-2 FXML CSS Reflection

旧时模样 提交于 2019-12-23 18:20:32
问题 Is it possible to use the javafx.scene.effect.Reflection in CSS for a FXML file? And something more general (I haven't found any answer for that yet): Can I do everthing with FXML and CSS that is available on the Java API (using JavaFX 2.2)? 回答1: Is it possible to use the javafx.scene.effect.Reflection in CSS for a FXML file? Not for JavaFX 2.2 - only dropshadow and innershadow effects can be set via CSS. Future JavaFX versions will probably add the ability to set more effects via CSS. For

How to find out if a transition is already running on a node?

∥☆過路亽.° 提交于 2019-12-23 17:08:55
问题 How can i find out if there is already a transition running on the node - for example a FadeTransition ? 回答1: You can always use the Transition statusProperty since Transition extends the Animation object. No need for another variable, you can simply: FadeTransition fade = new FadeTransition() fade.statusProperty().addListener(new ChangeListener<Status>() { @Override public void changed(ObservableValue<? extends Status> observableValue, Status oldValue, Status newValue) { if(newValue==Status

JavaFX KeyEvent and accented characters

╄→гoц情女王★ 提交于 2019-12-23 12:47:23
问题 I'm using a WebView with a contenteditable body as a rich text editor in JavaFX. It's working fine, but I need to listen for key presses. It works for the enter key and ASCII characters, but accented characters (like the icelandic á and é) don't fire any event. I tried KeyEvent.KEY_PRESSED and KeyEvent.KEY_TYPED, and neither of them fire for accented characters. InputMethodEvent does fire for accented characters, but if I setup a listener for that, it seems to automatically consume the event

How to make checkbox or combobox readonly in JavaFX

前提是你 提交于 2019-12-23 12:45:43
问题 How to make checkbox/combobox readonly in javaFX but not disabled. I tried consuming onAction event but it didn't work. checkBox.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { event.consume(); } }); Consuming all events like in code below works but I don't think it's a good solution: checkBox.addEventFilter(KeyEvent.ANY, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { event.consume(); } }); checkBox.addEventFilter

JSexception in webview of java fx?

本小妞迷上赌 提交于 2019-12-23 12:45:13
问题 My java Fx webview throws JS exception for following code. Can anyone explain me why? WebView webview = new WebView(); WebEngine webengine=webview.getEngine(); newtab.setText("Start Page"); newtab.setContent(webview); editTabset.getTabs().add(newtab); webengine.load("file:///E:/myproj/src/novuseditor/resources/html/clike.html");/*works till here*/ webengine.executeScript("document.getElementById('code').value=\"Hi\""); /*exception:netscape.javascript.JSException: TypeError: 'null' is not an