javafx-8

JavaFX: Reacting to Single, Double, and Triple Click

家住魔仙堡 提交于 2019-12-22 12:39:08
问题 I am trying to configure certain actions in response to number of mouse clicks. It seems to me that the single click and triple click get detected and applied. but the double click does not really work. I tried to do something like: if (doubleClick) else if (tripleClick) else if (singleClick). The order of checking did not help either, the action for the double click never gets triggered because that of the single click get triggered first. Any ideas on how to do this? 回答1: If you want to

JavaFX stage.setOnCloseRequest without function?

ε祈祈猫儿з 提交于 2019-12-22 12:23:51
问题 This is my Start-Methode. First i create a stage and set a title and a scene. And i wanna create a dialog if someone wants to close the window on the window-close-btn [X]. i thought i will catch this event with the setOnCloseRequest()-function. But i still can close all stages i open while runtime. @Override public void start(final Stage primaryStage) throws Exception { primaryStage.setTitle("NetControl"); primaryStage.setScene( createScene(loadMainPane()) ); primaryStage.setOnCloseRequest

Deriving Mapped Distinct Values into an ObservableList off another ObservableList?

こ雲淡風輕ζ 提交于 2019-12-22 11:23:17
问题 I have an interesting problem, and I am relatively new to JavaFX and I need to create a somewhat niche ObservableList implementation. Essentially, I need an ObservableList that maintains a list of mapped derived values off another ObservableList . I need to create an ObservableDistinctList<P,V> that accepts another ObservableList<P> and a Function<P,V> lambda as its constructor arguments. The ObservableDistinctList<P,V> maintains a list of distinct values off the applied Function<P,V> for

Need clarification of what is this Public API in JavaFX?

白昼怎懂夜的黑 提交于 2019-12-22 11:20:25
问题 I heart a lot about the term Public API from JavaFX speakers. What is Public API supposed to mean ? Conversely, is there a Private API ? 回答1: The most important things, you should understand about private and public API: At first, technicly, you can use both of them. At the second. when developers develop some programs, they think - this is for users, and this is our implementation. And when time goes, programs can change. And when developers add changes - if it is a change about private API

Deriving Mapped Distinct Values into an ObservableList off another ObservableList?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 11:20:06
问题 I have an interesting problem, and I am relatively new to JavaFX and I need to create a somewhat niche ObservableList implementation. Essentially, I need an ObservableList that maintains a list of mapped derived values off another ObservableList . I need to create an ObservableDistinctList<P,V> that accepts another ObservableList<P> and a Function<P,V> lambda as its constructor arguments. The ObservableDistinctList<P,V> maintains a list of distinct values off the applied Function<P,V> for

Triggering an Event by KeyCombination in javaFX

坚强是说给别人听的谎言 提交于 2019-12-22 10:35:34
问题 I am trying to set a shortcut to save a file. public static final KeyCombination saveShortcut = new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_ANY); I trigger an action by: sceneRoot.addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (saveShortcut.match(event)) { saveProject.fire(); } } }); However, the event gets fired by just hitting the S key. Any ideas on why so? 回答1: The default value for all the modifiers in

JavaFX freezing issue

匆匆过客 提交于 2019-12-22 10:30:36
问题 I was messing around with the JavaFX API, and for some reason this application seems to freeze after a (seemingly) random amount of time. It is an application that makes a red-green gradient pattern, and has a kinda cool animation to go along with it. When the application is run, press the Enter key, and the animation will start. After some amount of seconds (seemingly random as I said before) it will stop updating, but the timer continues to run, and so does the loop, and the setColor method

Eclipse Mars won't auto import JavaFX

老子叫甜甜 提交于 2019-12-22 09:23:43
问题 So, for every freaking time I want to use JavaFX 8 component, I have to google the exact name of the package, and manually type import packageName; I'll put in more detail. Let's say I want to create a StackPane StackPane stackPane = new StackPane(new ImageView(this.getClass().getResource("/images/about_icon.png").toString())); stackPane.setAlignment(Pos.CENTER); Several classes there. When I use ctrl + o ( cmd + o in Mac), then it should import the required package. But it doesn't. In fact,

expand TreeView (parent)nodes which contains selected item

心已入冬 提交于 2019-12-22 09:15:35
问题 I have a TreeView existing out of User objects. The TreeView represents the hierarchy of the Users: Master1 Super1 Super2 User1 User2 Super3 User3 Super4 Master2 ... Every TreeItem is Collapsed when the TreeView is initialized. However, it can be that when the FXML is loaded, a TreeItem object is passed through from another FXML file. Eg: User3 has been passed through: selectedUserTreeItem = (TreeItem<User>) currentNavigation.getPassthroughObject(); //this is the User3 TreeItem I try to use a

Animate new ListView entries in Javafx

感情迁移 提交于 2019-12-22 05:57:17
问题 The Problem Hi, I'm trying to write an application where every new entry in a ListView gets animated. Here is my code: public class BookCell extends ListCell<Book> { private Text text; private HBox h; public BookCell() { this.text = new Text(); this.h = new HBox(); this.h.getChildren().add(text); super.getStyleClass().add("book-list-cell"); super.itemProperty().addListener((obs,oldv,newv)->{ if(newv != null ) { if(getIndex() == this.getListView().getItems().size()-1 ) { //why does this get