javafx

Tree item select event in javafx2

烂漫一生 提交于 2020-01-10 17:30:13
问题 I have created the treeview in javafx2. i need to write the event for getting clicked node name. pls let me know how to do this? 回答1: use ChangeListener . Sample code : treeView.getSelectionModel().selectedItemProperty().addListener( new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { TreeItem<String> selectedItem = (TreeItem<String>) newValue; System.out.println("Selected Text : " + selectedItem.getValue()); // do what ever you

KeyListener JavaFX

爱⌒轻易说出口 提交于 2020-01-10 15:40:13
问题 I was looking on the internet but I didn't find good information for it. I'm trying to detect key presses every time the app is running. I'm using JavaFX and running it with FXML. I tryed a lot of thing but none work. Please help me. 回答1: You should check out the Ensemble sample. Here's the key listener code. /** * Copyright (c) 2008, 2012 Oracle and/or its affiliates. * All rights reserved. Use is subject to license terms. */ import javafx.application.Application; import javafx.scene.Group;

How to add JQuery onto JavaFx WebView

雨燕双飞 提交于 2020-01-10 06:05:07
问题 I've been trying to make the following work but I've been unsuccessful at integrating other similar solutions online onto my problem. The HTML file I'd like to add onto a webview is as follows: <!DOCTYPE html> <html> <head> <link href='../fullcalendar/fullcalendar.css' rel='stylesheet' /> <link href='../fullcalendar/fullcalendar.print.css' rel='stylesheet' media='print' /> <script src='../lib/jquery.min.js'></script> <script src='../lib/jquery-ui.custom.min.js'></script> <script src='..

How can I get keyboard inputs when not focused to the JavaFX stage?

耗尽温柔 提交于 2020-01-10 05:59:10
问题 I'm trying to understand how can I get the keyboard inputs without being focused to my JavaFX stage . Usually when I want to get a key input I'm doing this: public class Controller implements Initializable{ @FXML Button btn ; @FXML VBox vBox ; @Override public void initialize(URL location, ResourceBundle resources) { vBox.setOnKeyPressed(new EventHandler<javafx.scene.input.KeyEvent>() { @Override public void handle(javafx.scene.input.KeyEvent event) { System.out.print(event.getCode()); } });

Run debugger on javaFX project in android

人走茶凉 提交于 2020-01-10 05:55:29
问题 I am trying to rebuild an old javafx project on android. Currently I am using javafxports to do so. The problem is I can't debug it, this is how the project hierarchy looks: The application is started from DisplayClient . So far I am able to log messages using the device monitor. Can you please tell me if it is possible to attach a debugger and if it is how? If any further information is needed I would be happy to give it. 回答1: You can easily attach a debugger to your IntelliJ IDE while

Loading an image in ImageView through code

为君一笑 提交于 2020-01-10 05:29:21
问题 I have built my application using scenebuilder for javafx. I have a form where a person has to upload an image. I used this code public void photoChooser(ActionEvent evt) { System.out.println("photoChooser method is called"); try{ FileChooser fileChooser= new FileChooser(); fileChooser.setTitle("Choose a file"); File file = fileChooser.showOpenDialog(stagehere); if(file != null){ System.out.println(file); String img = file.toString(); //Image image = new ImageIcon(img); try{ // image= new

Resize JavaFX tab when double click

久未见 提交于 2020-01-10 05:19:05
问题 I have this simple example with JavaFX tabs: public class test extends Application { private BorderPane root; // Navigation Utilization private ActionTabs actiontabs; @Override public void start(Stage primaryStage) { // Set Main Window Label primaryStage.setTitle("Desktop Client"); Image iv = new Image(getClass().getResource("/images/internet-icon.png").toExternalForm()); primaryStage.getIcons().add(iv); root = new BorderPane(); root.setLeft(getLeftHBox(primaryStage, root)); Scene scene = new

JavaFX: How to make my custom component use all available space from parent layout?

大城市里の小女人 提交于 2020-01-10 05:01:05
问题 I´m trying to make a custom component to javafx, so I make my class extends javafx.scene.control.Control and on constructor it draws it´s contents. My doubts are: how do I make it "grow" to fill all the space available on its parent layout? Like when I place a TextArea instead... This is an shrink example of what I´m doing: @Override public void start(Stage primarystage) throws Exception { BorderPane bpane = new BorderPane(); mainscene = new Scene(bpane, 800, 600); ((BorderPane) this

Is it possible to use an existing Applet within a JavaFX application (desktop)

筅森魡賤 提交于 2020-01-10 04:22:21
问题 I can't seem to find anything on this - other than it can't be embedded in a web view. I currently have an image viewing product which is accessed via an applet and controlled via JavaScript from an HTML page. I am investigating a client application using JavaFX and it would likely need to access that applet. I attempted to embed it into the WebView and that didn't work. Searching on this site stated that webview doesn't support plug in technology. This is to build an applet with Java FX -

Disable TreeItem's default expand/collapse on double click JavaFX 2.2

大兔子大兔子 提交于 2020-01-10 04:16:12
问题 I am working on a JavaFX 2.2 project and i want to set custom handling of the mouse (double) click event on a TreeItem. Using treeview.setOnMouseClicked i fire my code without errors but the problem is that the TreeItem, on every mouse double click, it toggles between expanded and collapsed. I suppose that this is the default behavior, but how i disable it?? 回答1: I had the same issue and solved it in time using EventDispatcher . class TreeMouseEventDispatcher implements EventDispatcher {