javafx-8

Changing table row color using a property that would not be visible in any column

僤鯓⒐⒋嵵緔 提交于 2019-12-12 05:14:49
问题 I need to change the table row color using a property that would not be visible in any column of a tableview . I did the following: create a model class Person ( serialNumber , first , last ). create an observableList of Person using an extractor. create two tableviews( tableview1 , tableview2 ) and one listview that all sharing the same data. tableview1 has a serialCol1 column with a visible property set to false. I want to change tableview1 row color using the serialNumber property that is

JavaFX change Pane color from a different class

妖精的绣舞 提交于 2019-12-12 04:57:12
问题 I have a question. I want to change the color of a pane from another controller class. I am using this code: FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/Menu.fxml")); try { Parent loaded = (Parent) loader.load(); } catch (IOException e) { e.printStackTrace(); } MenuController controller = (MenuController) loader.getController(); Platform.runLater(new Runnable() { @Override public void run() { Pane pane = controller.getRedPane(); pane.setBackground(new Background(new

Proper way to move a JavaFx8 node around

送分小仙女□ 提交于 2019-12-12 04:52:50
问题 I am working on an app which needs to move nodes around on a pane. I've just recently started learning javaFx 8 so I have bare understanding of the workflow, but while I managed to get a working draggable node code working, it uses node.setTranslateX() and .setTranslateY(). This is all fine, until I tried to make the node snap to a grid that divides the scene area in both 10 height and width subdivisions. Whenever I try to use modulos to get some sort of snapping going on, I'm stuck with the

javafx change style of a node frequently not by CSS

二次信任 提交于 2019-12-12 04:44:22
问题 Example is 3 nodes in stage: button, colorpicker and comboBox(for change text size) . Button btn = new Button("Change color and size"); ColorPicker colorpicker = new ColorPicker(); ComboBox sizebox = new ComboBox(); sizebox.getItems().addAll("13", "15", "16", "17", "18", "19", "20", "22"); ColorPicker will change the button background color by customer, and sizebox will change the text size by customer. colorpicker.setOnAction(e-> btn.setStyle("-fx-background- color:#"+Integer.toHexString

How can I kill a service or task in JavaFx?

南笙酒味 提交于 2019-12-12 04:36:09
问题 How I can stop a service or thread safely for prevent an IO exception? I have tried with the method cancel, but this isn't work. What is the guidelines ? 回答1: You have to check if cancel was requested inside your Task-Loop: package test; import javafx.concurrent.Task; public class TestTask extends Task<String> { @Override protected String call() throws Exception { StringBuilder builder = new StringBuilder(); int max = 1000; for (int i = 0; i < max; i++) { if (isCancelled()) { throw new

JavaFX 8: Missing caret in switch-editable ComboBox

故事扮演 提交于 2019-12-12 04:32:42
问题 The caret of an editable ComboBox is missing after porting an application from JavaFX 2.2 to JavaFX 8. The ComboBox should be switched to editable on selecting an item. I tested it under Windows 8.1 with Oracle JDK 1.8 Update 102 and Update 112. When the ComboBox lost focus and regained focus, the caret is visible. It actually works on JavaFX 2.2 after changing the lambda to an interface implementation and removing the Platform.runLater . I included a SSCCE for testing: import javafx

OSX System menubar not working in JavaFX

只愿长相守 提交于 2019-12-12 04:20:04
问题 I was trying to use NSMenuFX from https://github.com/codecentric/NSMenuFX to make a JavaFX app use the MacOS System MenuBar, and it didn't work because of this method returning always false . Toolkit.getToolkit().getSystemMenu().isSupported() The method is from the package : com.sun.javafx.tk.Toolkit . Going deeper in the code I've found that Toolkit.getToolkit().getSystemMenu().isSupported() calls a method from com.sun.glass.ui.Application that returns always false too. protected boolean

JavaFX8 - drag a pane within a ScrollPane

旧巷老猫 提交于 2019-12-12 03:46:49
问题 Base on this comment https://stackoverflow.com/a/29530135/1387524 I added a ScrollPane to use scrolling when the canvas is moved outside of the visible area. When I drag the canvas to the right or the bottom the scrollbars are displayed. But when I drag to the left or to the top nothing happens. What am I missing? import javafx.application.Application; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.event.EventHandler; import

Programmatically resize TableColumns in JavaFX

为君一笑 提交于 2019-12-12 03:37:24
问题 I am trying to make a TableView to programmatically resize its columns at startup in order to fit its content, to achieve this I found a method which works great when bound to a listener (for example #onKeyPressed ). But when i try to bind it to the showingProperty() of the primaryStage in order to call it without any user action it throws a NullPointerException on columnToFitMethod.invoke(tableView.getSkin(), column, -1) . In a previous post I exposed a similar problem, the difference was

FXMLLoader.constructLoadException occuered when app gets initialize

半城伤御伤魂 提交于 2019-12-12 03:27:30
问题 I have build contact manager app and When I try to run it I got following error at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at `enter code here`com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) at java.lang.Thread.run