javafx-2

In JavaFX how to add combobox with data in table view

家住魔仙堡 提交于 2019-12-31 05:57:05
问题 I have tried a lot but not able to populate all values in the data base into my combo box table cell. Controller.java public class controller { GetConnection gc = new GetConnection(); PreparedStatement pst; ResultSet rs; Statement st; private ObservableList<Users> datas = FXCollections.observableArrayList(); public controller() { } @FXML private TableView<Users> table; @FXML private TableColumn<Users, String> c1; @FXML private void editable() { List<String> names = new ArrayList<String>();

Play one song after the another javafx

喜欢而已 提交于 2019-12-31 04:41:22
问题 I'm trying to get song location from DB and play one song after the another but in here it plays the last song in the database and stops playing. I want to play the first song, then the second song. public class FX_Musicplayer extends Application { public static void main(String[] args) { launch(args); } @Override public void start(final Stage stage) throws Exception { final ArrayList<String> list = new ArrayList<String>(); try { Statement stmt = null; // connect to database radio Connection

JavaFX: Handle ComboBox selection event which is inside the TableView Column

此生再无相见时 提交于 2019-12-31 04:39:09
问题 I have a javafx TableView and I want custom controls inside the columns. Say I want a TextField in column1 and ComboBox in column2 and DatePicker in column3 . I know that I should create a class that extends TableCell and override the updateItem() method.... But I read that specifically for this purpose we have default classes like ComboBoxTableCell , TextFieldTableCell etc in the cell package and it is recommended to use them. So I'm able to achieve this with the below code.

Adding a TilePane instantiated in .java files to FXML

泄露秘密 提交于 2019-12-31 04:20:15
问题 I'm trying to add a TilePane with ImageView children to a scene in JavaFX. Currently, my FXML is loading an empty TilePane. The current FXML line that i have making the TilePane is <TilePane id="MapPane" fx:id="mapPane" layoutX="3.0" layoutY="0.0" prefColumns="9" prefHeight="560.0" prefTileHeight="112.0" prefTileWidth="112.0" prefWidth="1277.0" visible="true"\> where mapPane is the name of the variable in my .java file controller: /* * To change this template, choose Tools | Templates * and

JavaFx, event interception/consumption

我是研究僧i 提交于 2019-12-31 02:10:09
问题 I've got this partial scenegraph tree : CustomPane (with onMouseClicked Handler) → ChildNode (with onMousePressed Handler) When I catch the MousePressed event in the ChildNode, I can consume it, so that the parent doesn't receive a MousePressed event. But I would like to consume the associated MouseClicked event. So that pressing the mouse on the Child doesn't fire a MouseClicked event on the Parent. 回答1: You can add specific ChildNode#onMouse... handlers which will consume all events. or

JavaFx, event interception/consumption

混江龙づ霸主 提交于 2019-12-31 02:10:08
问题 I've got this partial scenegraph tree : CustomPane (with onMouseClicked Handler) → ChildNode (with onMousePressed Handler) When I catch the MousePressed event in the ChildNode, I can consume it, so that the parent doesn't receive a MousePressed event. But I would like to consume the associated MouseClicked event. So that pressing the mouse on the Child doesn't fire a MouseClicked event on the Parent. 回答1: You can add specific ChildNode#onMouse... handlers which will consume all events. or

Is it possible to set a JavaFX static property in CSS?

夙愿已清 提交于 2019-12-31 01:50:25
问题 Sample FXML with the BorderPanel.alignment "static property": <BorderPane> <top> <Label text="My Label" BorderPanel.alignment="CENTER"/> </top> </BorderPane> The CSS-supported version: <BorderPane stylesheets="Style.css"> <top> <Label text="My Label" styleClass="labelClass"/> </top> </BorderPane> Style.css would be: .labelClass { -fx-borderpanel-alignement: center } 回答1: For JavaFX versions 2.0 to 2.2 => no you cannot set the static layout properties via css. You can create a feature request

Scene.getStylesheets().add() not working inside jar file

我只是一个虾纸丫 提交于 2019-12-30 22:54:21
问题 As long as I run my project directly from Eclipse, I have no problem with that: scene.getStylesheets().add(getClass().getResource("/stylesheet.css").toExternalForm()); But as soon as I run this code inside of a jar file, the resource is not found ( NullPointerException ). I tried moving the css file to my src folder and then only stylesheet.css as path instead of /stylesheet.css , but this leads to the same problem: Works fine using Eclipse, but not from the jar. Hint : I am using Zonskis

Creating a large body of text with different styles - JavaFX FXML

老子叫甜甜 提交于 2019-12-30 22:51:35
问题 In the fxml class of my JavaFx application I want to add a large body of text using minimal components (instead of adding multiple labels per line). I would also like to create varying styles of text in the same component. What component should I use (e.g TextArea) and how would I go about create multiple styles inside it (using css). 回答1: Use a TextFlow and add Text to it. You can style individual Text component with different style using css on them. Complete example : import javafx

JavaFX KeyEvent returns KeyCode.UNDEFINED

爷,独闯天下 提交于 2019-12-30 18:27:13
问题 I created a simple JavaFX application that receives input from the user in a TextField. I attached the KeyTyped event from SceneBuilder to the controller. My function looks like this: @FXML private void keyTyped(KeyEvent event) { System.out.println(event.getCode().equals(KeyCode.ENTER)); } This function always prints out UNDEFINED when I type the enter key. Any ideas on how to fix this? Other letters I type seem to have the same problem as well. 回答1: KeyTyped is a special event. It doesn't