javafx-8

JavaFX-CSS: How to “move” style of parent to a child?

假如想象 提交于 2020-01-01 16:46:26
问题 The trigger for this was a quick experiment to solve TreeItem selection width: the requirement is to highlight only the text, not the whole tree cell. Nothing easier than that (said Frederik :) implement a custom TreeCell with a Label as graphic (and configure the label with the item as needed) remove the selection style (mostly the highlight background from the cell add the highlight style to the label Something like (a runnable example using this is at the end): public static class

JavaFX-CSS: How to “move” style of parent to a child?

扶醉桌前 提交于 2020-01-01 16:46:22
问题 The trigger for this was a quick experiment to solve TreeItem selection width: the requirement is to highlight only the text, not the whole tree cell. Nothing easier than that (said Frederik :) implement a custom TreeCell with a Label as graphic (and configure the label with the item as needed) remove the selection style (mostly the highlight background from the cell add the highlight style to the label Something like (a runnable example using this is at the end): public static class

Change Color of Background in javaFX Canvas

倖福魔咒の 提交于 2020-01-01 14:53:27
问题 How do we change the background of JavaFX canvas? The only solution I have now is: GraphicsContext gc = canvas.getGraphicsContext2D(); gc.setFill(Color.BLUE); gc.fillRect(0, 0, canvas.getWidth(), canvas.getHeight()); Is there another solution except drawing a rectangle? I searched in CSS but canvas doesn't have -fx-background-color 回答1: The canvas is essentially "blank" (i.e. transparent) unless you draw onto it. You can create the effect of a background by placing it into a layout pane and

How to detect keys

孤街醉人 提交于 2020-01-01 06:11:35
问题 I want to create table in which I want to configure hot key shortcuts. I have this simple table: public static final String Column1MapKey = "A"; public static final String Column2MapKey = "B"; private ObservableList<Map> generateDataInMap() { int max = 110; ObservableList<Map> allData = FXCollections.observableArrayList(); for (int i = 1; i < max; i++) { Map<String, String> dataRow = new HashMap<>(); String value1 = "A" + i; String value2 = "B" + i; dataRow.put(Column1MapKey, value1); dataRow

How to detect keys

微笑、不失礼 提交于 2020-01-01 06:11:11
问题 I want to create table in which I want to configure hot key shortcuts. I have this simple table: public static final String Column1MapKey = "A"; public static final String Column2MapKey = "B"; private ObservableList<Map> generateDataInMap() { int max = 110; ObservableList<Map> allData = FXCollections.observableArrayList(); for (int i = 1; i < max; i++) { Map<String, String> dataRow = new HashMap<>(); String value1 = "A" + i; String value2 = "B" + i; dataRow.put(Column1MapKey, value1); dataRow

How does JavaFX 8 start the JavaFX Application thread in a nearly empty Application class?

戏子无情 提交于 2020-01-01 04:54:12
问题 Lets say, we have the following class: import javafx.application.Application; import javafx.stage.Stage; public class Test extends Application { public Test() { System.out.println("Constructor"); } @Override public void start(Stage primaryStage) throws Exception { System.out.println("start"); } public static void main(String... args) { System.out.println("main"); } } It's derived from Application but it doesn't use any of its methods. Usually you start a JavaFX application by calling launch

How to drag an undecorated window (stage) of JavaFX

百般思念 提交于 2020-01-01 04:35:07
问题 I have this undecorated window: public static void initStartPage(final Stage primaryStage) { final Stage startPage = new Stage(); startPage.initStyle(StageStyle.UNDECORATED); //startPage.initOwner(primaryStage); //startPage.toFront(); Scene scene = new Scene(agentsPanel(), 900, 500); startPage.setScene(scene); startPage.show(); } I would like to know how I can make it a draggable undecorated window ? I want to change its position when the user selects the window with the right mouse button

Default JavaFX-CSS

余生长醉 提交于 2020-01-01 04:16:17
问题 Is there any way to see the applied CSS-Rules for JavaFX-Elements? Or there is a published reference with the default CSS-Rules available? I would like, for example , to know the color of Toolbar's border. 回答1: The CSS file is located in javafxrt.jar at jfxrt.jar!/com/sun/javafx/scene/control/skin/caspian/caspian.css . Unfortunately, there is no API access to the CSS styles of an element as of now, though that is apparently being discussed for JavaFX 2.2. 回答2: Here is the extracted caspian

JavaFX: Styling application with CSS Selectors

拜拜、爱过 提交于 2020-01-01 03:05:27
问题 I have a couple of questions about styling a JavaFX application with CSS Selectors (such as: .table-view for every TableView ). I have created a main CSS-file, in which I want to define the universal style properties for my application. For example: every TableView gets the same color in every screen. I just import the Main.css in every .css that is associated with a .fxml file. Now I would like to style every HBox in a 'sidebar' the same way. I have tried it like this (as suggested in Oracle

JavaFX: Styling application with CSS Selectors

谁说胖子不能爱 提交于 2020-01-01 03:05:09
问题 I have a couple of questions about styling a JavaFX application with CSS Selectors (such as: .table-view for every TableView ). I have created a main CSS-file, in which I want to define the universal style properties for my application. For example: every TableView gets the same color in every screen. I just import the Main.css in every .css that is associated with a .fxml file. Now I would like to style every HBox in a 'sidebar' the same way. I have tried it like this (as suggested in Oracle