I'm a JavaFX newbie and, for some reason, my data doesn't show up in the tableview.
Controller Class:
public class TxstController implements Initializable {
#FXML private Label label;
#FXML private TextField searchBar;
#FXML private Button searchButton;
#FXML private ListView dateList;
#FXML private TableView<Service> serviceTable;
#FXML private TableColumn<Service, Integer> qntColumn;
#FXML private TableColumn<Service, String> descColumn;
#FXML private TableColumn<Service, Double> priceColumn;
#FXML
private void handleSearchButton(ActionEvent event) {
//do stuff when searchButton get clicked
List<String> lista = new ArrayList<>();
lista.add("Queijo");
lista.add("Azeitonas");
lista.add("Cebola");
fillListWith(lista);
}
#FXML
private void textFieldKeyHandler(KeyEvent event){
if(event.getCode() == KeyCode.ENTER){
//do stuff when in text field you click enter
}
}
private void fillListWith(List<String> list){
//adds string list at param to dateList
dateList.setItems(FXCollections.observableList(list));
}
#Override
public void initialize(URL url, ResourceBundle rb) {
qntColumn.setCellValueFactory(new PropertyValueFactory<>("qnt"));
descColumn.setCellValueFactory(new PropertyValueFactory<>("desc"));
priceColumn.setCellValueFactory(new PropertyValueFactory<>("price"));
ObservableList<Service> lista = FXCollections.observableArrayList();
lista.add(new Service(3,"Queijo com ",19.30));
lista.add(new Service(2,"asdasasd",5.21));
lista.add(new Service(3,"Queijo com ",19.30));
lista.add(new Service(3,"Queijo com ",19.30));
lista.add(new Service(3,"Queijo com ",19.30));
lista.add(new Service(3,"Queijo com ",19.30));
serviceTable.setItems(lista);
}
Service class:
class Service {
private int qnt;
private String desc;
private double price;
public Service(int qnt,String desc, double price){
this.qnt = qnt;
this.desc = desc;
this.price = price;
}
public int getqnt(){
return this.qnt;
}
public String getdesc(){
return this.desc;
}
public double getprice(){
return this.price;
}
public void setqnt(int qnt){
this.qnt = qnt;
}
public void setdesc(String desc){
this.desc = desc;
}
public void setprice(double price){
this.price = price;
}
FXML File:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane id="AnchorPane" prefHeight="758.0" prefWidth="848.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="elteste.TxstController">
<children>
<TextField fx:id="searchBar" layoutX="110.0" layoutY="124.0" onKeyPressed="#textFieldKeyHandler" prefHeight="26.0" prefWidth="487.0" />
<Button fx:id="searchButton" layoutX="608.0" layoutY="124.0" mnemonicParsing="false" onAction="#handleSearchButton" prefHeight="26.0" prefWidth="84.0" text="Pesquisar" />
<ListView fx:id="dateList" layoutX="18.0" layoutY="158.0" onMouseClicked="#listMouseSelectHandler" prefHeight="575.0" prefWidth="175.0" />
<Label layoutX="30.0" layoutY="128.0" prefHeight="16.0" prefWidth="69.0" text="Matricula:" textAlignment="CENTER" />
<Button layoutX="702.0" layoutY="124.0" mnemonicParsing="false" text="Adicionar Servico" />
<Label fx:id="label" layoutX="369.0" layoutY="54.0" prefHeight="37.0" prefWidth="207.0" text="Label" />
<TableView fx:id="serviceTable" layoutX="207.0" layoutY="158.0" prefHeight="575.0" prefWidth="603.0">
<columns>
<TableColumn fx:id="qntColumn" prefWidth="113.0" text="Quantidade" />
<TableColumn fx:id="descColumn" prefWidth="362.0" text="Descricão" />
<TableColumn fx:id="priceColumn" minWidth="0.0" prefWidth="127.0" text="Preco" />
</columns>
</TableView>
</children>
</AnchorPane>
There are no erros, and when the table pops up, i can select the rows, that are filled, for example, if the list has 3 objects, i can select 3 rows, the others i cant, but, for some reason, the content doesnt show up.
You named the getters and setters wrong in Service.
Name them according to the camelCase naming convention:
public void setQnt(int qnt){
this.qnt = qnt;
}
Related
I have two controllers:
Main which contains TableView Tab which displays SQLITE database tables (which contain different number of columns) in tabular format, and
Rem which contains a button which dictates which database to display (there are many such controllers).
Now if I create a method in Main which is responsible for updating and displaying TableView contents, how do I use that method in other controller?
I created two static ObservableList variables columns and rows and bind them to Tab in Main's initialize.
APP.java
public class App extends Application {
private static Scene scene;
public static Connection conn;
#Override
public void start(Stage stage) throws IOException {
try{
conn=java.sql.DriverManager.getConnection("jdbc:sqlite:sample.db");
if(conn!=null){
conn.createStatement().execute("CREATE TABLE IF NOT EXISTS tab1(Field0 TEXT, Field1 TEXT, Field2 TEXT);");
conn.createStatement().execute("CREATE TABLE IF NOT EXISTS tab2(Field3 TEXT, Field4 TEXT);");
}
}catch(Exception ex){
System.out.println(ex);
}
scene = new Scene(loadFXML("main"), 640, 480);
stage.setScene(scene);
stage.show();
}
private static Parent loadFXML(String fxml) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));
return fxmlLoader.load();
}
public static void main(String[] args) {
launch();
}
public static ResultSet getRS(String table){
String sql="SELECT * FROM "+table;
ResultSet rs=null;
try{
rs=conn.createStatement().executeQuery(sql);
}catch(Exception ex){
System.out.println(ex);
}
return rs;
}
}
MAIN.FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.VBox?>
<VBox xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nic.testfx.Main">
<children>
<MenuBar>
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" onAction="#loadRem" text="Load Remaining" />
</items>
</Menu>
</menus>
</MenuBar>
<TableView fx:id="Tab" prefHeight="200.0" prefWidth="200.0" />
<VBox fx:id="remPane" prefHeight="200.0" prefWidth="100.0" />
</children>
</VBox>
MAIN.JAVA
public class Main implements Initializable {
#FXML
public TableView<ObservableList<String>> Tab;
#FXML
private VBox remPane;
#Override
public void initialize(URL url, ResourceBundle rb) {
Tab.itemsProperty().bind(getTabRow());
}
public void makeTable(ResultSet rs){
try{
var rsm=rs.getMetaData();
ObservableList<TableColumn<ObservableList<String>,String>>cols=FXCollections.observableArrayList();
for(int i=0;i<rsm.getColumnCount();i++){
final int j=i;
TableColumn<ObservableList<String>,String> col=new TableColumn(rsm.getColumnName(i+1));
col.setCellValueFactory(param->new SimpleStringProperty(param.getValue().get(j)));
cols.add(col);
}
ObservableList<ObservableList<String>> arows=FXCollections.observableArrayList();
while(rs.next()){
ObservableList<String> row=FXCollections.observableArrayList();
for(int i=1;i<=rsm.getColumnCount();i++){
row.add(rs.getString(i));
}
arows.add(row);
}
setTable(cols,arows);
}catch(Exception ex){
System.out.println(ex);
}
}
private static final ObservableList<TableColumn<ObservableList<String>,String>> columns=FXCollections.observableArrayList();
private static final javafx.beans.property.ListProperty<ObservableList<String>> rows=new javafx.beans.property.SimpleListProperty();
private javafx.beans.property.ListProperty getTabRow(){
Tab.getColumns().clear();
Tab.getColumns().addAll(columns);
return rows;
}
private static void setTable(ObservableList<TableColumn<ObservableList<String>,String>>c,ObservableList<ObservableList<String>> r){
columns.setAll(c);
rows.set(r);
}
#FXML
private void loadRem(ActionEvent event) {
try{
for(int i=remPane.getChildren().size()-1;i>=0;i--){
remPane.getChildren().remove(i);
}
javafx.fxml.FXMLLoader fxmlLoader=new javafx.fxml.FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("rem.fxml"));
javafx.scene.layout.Pane panel=fxmlLoader.load();
remPane.getChildren().add(panel);
makeTable(App.getRS("tab1"));
}catch(Exception ex){
System.out.println(ex);
}
}
}
REM.FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.VBox?>
<VBox alignment="CENTER" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nic.testfx.Rem">
<children>
<Button fx:id="btn" mnemonicParsing="false" onAction="#loadTab" text="Button" />
</children>
</VBox>
REM.JAVA
public class Rem implements Initializable {
#FXML
private Button btn;
#Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
#FXML
private void loadTab(ActionEvent event) {
try{
var fxml=new javafx.fxml.FXMLLoader(App.class.getResource("main.fxml"));
fxml.load();
Main controller=fxml.getController();
var rs=App.getRS("tab2");
controller.makeTable(rs);
}catch(Exception ex){
System.out.println(ex);
}
}
}
OK I got it.
Created a java class which encapsulate method makeTable:
MODEL.JAVA
public class Model{
private final TableView table;
public Model(TableView t){
this.table=t;
}
public void makeTable(ResultSet rs){
ObservableList<TableColumn<ObservableList<String>,String>>tabcols=FXCollections.observableArrayList();
ObservableList<ObservableList<String>>tabrows=FXCollections.observableArrayList();
//Create TableColumns and add to tabcols;
while(rs.next()){
//Create ObservableList<String>, get data from rs, and add to tabrows
}
this.table.getColumns().setAll(tabcols);
this.table.getItems().setAll(tabrows);
}
}
Next, in Controller file Main.java created a static instance of Model:
MAIN.JAVA
public class Main implements Initializable{
#FXML
private TableView<ObservableList<String>> Tab;
static Model model;
#Override
public void initialize (URL url, ResourceBundle rb){
model=new Model(Tab);
}
}
Now I can use model from Rem controller:
REM.JAVA
public class Rem implements Initializable{
#FXML
private Button btn;
#Override
public void initialize (URL url, ResourceBundle rb){
//TODO
}
#FXML
private void loadTab(ActionEvent event){
var rs=App.getRS("tab2");
Main.model.makeTable(rs);
}
I'm in the middle of a school project, but I'm stuck...
In Scene Builder there is an OnKeyPressed and an OnKeyReleased 'method', and when I assign my own method (See code further down) I want to check if I'm pressing the left or right arrow key.
The problem is, OnKeyReleased works fine, but the OnKeyPressed only works when I hold down shift!
Does anyone know the cause of this issue? and if so, how it can be fixed/worked around?
(I'm on a MacBook, could this have anything to do with it?)
Thanks :)
Method for OnKeyPressed:
#FXML
private void Input(KeyEvent e)
{
if(e.getCode().equals(KeyCode.LEFT))
{
System.out.println("Pressed left arrow key");
}
}
FullCode:
package seasweeper.seasweeper;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
public class SecondaryController implements Initializable {
#FXML
private Label Label_Character;
/**
* Initializes the controller class.
*/
#Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
#FXML
private void switchToPrimary() throws IOException
{
App.setRoot("primary");
}
#FXML
private void Input(KeyEvent e)
{
if(e.getCode().equals(KeyCode.LEFT))
{
System.out.println("Pressed left");
}
System.out.println("KeyCode: " + e.getCode());
}
}
FXML code:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onKeyPressed="#moveLeft" onKeyReleased="#moveLeft" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seasweeper.seasweeper.PacificController">
<children>
<Button layoutX="422.0" layoutY="64.0" mnemonicParsing="false" onAction="#switchToPrimary" prefHeight="27.0" prefWidth="164.0" text="Switch to Primary" />
<Label layoutX="489.0" layoutY="31.0" text="Pacific" />
<Label fx:id="Label_Character" layoutX="273.0" layoutY="192.0" text="Character" />
</children>
</AnchorPane>
Other Scene Controller:
package seasweeper.seasweeper;
import java.io.IOException;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
public class PrimaryController {
#FXML
private Button Button_Arctic;
#FXML
private Button Button_Southern;
#FXML
private Button Button_Pacific;
#FXML
private Button Button_Atlantic;
#FXML
private Button Button_Indian;
#FXML
private Button Button_Pacific1;
#FXML
private void switchToPacific() throws IOException {
App.setRoot("pacific");
}
#FXML
private void switchToSouthern() throws IOException {
App.setRoot("southern");
}
#FXML
private void switchToAtlantic() throws IOException {
App.setRoot("atlantic");
}
#FXML
private void switchToIndian() throws IOException {
App.setRoot("indian");
}
#FXML
private void switchToArctic() throws IOException {
App.setRoot("arctic");
}
}
Other FXML:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seasweeper.seasweeper.PrimaryController">
<children>
<Button fx:id="Button_Arctic" layoutX="226.0" layoutY="14.0" mnemonicParsing="false" onAction="#switchToArctic" prefHeight="77.0" prefWidth="148.0" text="Arctic" />
<Button fx:id="Button_Southern" layoutX="226.0" layoutY="309.0" mnemonicParsing="false" onAction="#switchToSouthern" prefHeight="77.0" prefWidth="148.0" text="Southern" />
<Button fx:id="Button_Pacific" layoutX="14.0" layoutY="162.0" mnemonicParsing="false" onAction="#switchToPacific" prefHeight="77.0" prefWidth="148.0" text="Pacific" />
<Button fx:id="Button_Atlantic" layoutX="226.0" layoutY="162.0" mnemonicParsing="false" onAction="#switchToAtlantic" prefHeight="77.0" prefWidth="148.0" text="Atlantic" />
<Button fx:id="Button_Indian" layoutX="438.0" layoutY="162.0" mnemonicParsing="false" onAction="#switchToIndian" prefHeight="77.0" prefWidth="148.0" text="Indian" />
<Button fx:id="Button_Shop" layoutX="556.0" layoutY="14.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="30.0" text="\$" textFill="#009712" />
</children>
</AnchorPane>
On the same issue I changed OnKeyPressed from AnchorPane to some Button on that AnchorPane and OnKeyPressed works fine with arrows :)
#Override
public void initialize(URL location, ResourceBundle resources) {
someButton.addEventHandler(KeyEvent.KEY_PRESSED,
new EventHandler<KeyEvent>() {
#Override
public void handle(KeyEvent event) {
switch (event.getCode().toString()) {
// your logic here
}
event.consume();
}
});
}
This one is a little tricky, but still relatively simple:
Node node = null;
node.setOnKeyPressed(new EventHandler<KeyEvent>() {
#Override
public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.KP_UP) { // KeyPressed_UP
// Do something
}
if (event.getCode() == KeyCode.KP_DOWN) { // KeyPressed_DOWN
// Do something
}
if (event.getCode() == KeyCode.KP_LEFT) { // KeyPressed_LEFT
// Do something
}
if (event.getCode() == KeyCode.KP_RIGHT) { // KeyPressed_RIGHT
// Do something
}
}
});
Remember to change "node" with your object (it could be a Scene, AnchorPane -or any kind of pane-, buttons, etc).
I created a table view, linked it with my model and put into fxml like this:
Main.java
public class Main extends Application {
#Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("table.fxml"));
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Controller.java
public class Controller {
#FXML
private javafx.scene.control.TableView<TableView> tableView;
#FXML
public void initialize() {
ObservableList<TableView> data = tableView.getItems();
data.add(new TableView("Item1", true));
data.add(new TableView("Item2", false));
}
}
TableView.java
public class TableView {
private SimpleStringProperty text;
private SimpleBooleanProperty check;
TableView(String text, boolean check) {
this.text = new SimpleStringProperty(text);
this.check = new SimpleBooleanProperty(check);
}
public boolean getCheck() {
return check.get();
}
public SimpleBooleanProperty checkProperty() {
return check;
}
public void setCheck(boolean check) {
this.check.set(check);
}
public String getText() {
return text.get();
}
public SimpleStringProperty textProperty() {
return text;
}
public void setText(String text) {
this.text.set(text);
}
}
CheckBoxTableCellFactory.java
public class CheckBoxTableCellFactory<S, T> implements Callback<TableColumn<S, T>, TableCell<S, T>> {
public TableCell<S, T> call(TableColumn<S, T> param) {
return new CheckBoxTableCell<>();
}
}
table.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.cell.PropertyValueFactory?>
<?import table.CheckBoxTableCellFactory?>
<VBox prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="table.Controller">
<SplitPane focusTraversable="true" VBox.vgrow="ALWAYS">
<Pane prefHeight="200.0" prefWidth="200.0">
<TableView fx:id="tableView" layoutX="6.0" layoutY="4.0" prefHeight="406.0" prefWidth="694.0">
<columns>
<TableColumn prefWidth="75.0" text="Check">
<cellValueFactory>
<PropertyValueFactory property="check" />
</cellValueFactory>
<cellFactory>
<CheckBoxTableCellFactory />
</cellFactory>
</TableColumn>
<TableColumn prefWidth="200.0" text="Text">
<cellValueFactory>
<PropertyValueFactory property="text"/>
</cellValueFactory>
</TableColumn>
</columns>
</TableView>
</Pane>
</SplitPane>
</VBox>
I looks good -
screenshot
but checkboxes are disabled - I cannot check/un-check them. When I click on them, they don't change their state (checked/un-checked). How to fix it?
By default, a TableView is not editable meaning any custom controls within the TableView are also disabled.
You can enable editing by either updating your FXML definition of the TableView to include editable="true" or in your controller with tableView.setEditable(true);.
I am unable to extract user input from textfield in javafx.
When I click the button, I want the text from the textfield should be printed in console but it displays nothing. Here is a screenshot: 1
Controller Class:
public class FXMLDocumentController implements Initializable {
#FXML
private Label label;
#FXML
private TextField textField;
#FXML
private Button button;
#FXML
private void handleButtonAction(ActionEvent event) {
textField = new TextField();
System.out.println("You clicked me!" + textField.getText());
label.setText("Hello World!");
}
#Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
FXML:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320"
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="javafxapplication4.FXMLDocumentController">
<children>
<Button fx:id="button" layoutX="126" layoutY="90"
onAction="#handleButtonAction" text="Click Me!" />
<Label fx:id="label" layoutX="126" layoutY="120" minHeight="16"
minWidth="69" />
<TextField fx:id="textField" layoutX="86.0" layoutY="137.0" />
</children>
</AnchorPane>
What is the mistake, and can you provide an explanation if possible?
Thank You.
The problem is here textField = new TextField(); you are redefining the textField instance that's why you're getting empty value, but you're already instanciating the TextField with the #FXML annotation so to retrieve the text inside that textField (already defined before) change your method to this :
#FXML
private void handleButtonAction(ActionEvent event) {
System.out.println("You clicked me!" + textField.getText());
label.setText("Hello World!");
}
I have a ListSelectionView (from the ControlsFX library) in JavaFX and I need it to display a set of values when a particular button is clicked. It displays the values when I place the add the contents into it in the initialize method. But when I place the same code in the event action method of a button it doesn't display. I have another method which gets the Source items and Target items from the ListSelectionView and displays them. Even though the ListSelectionView isn't displaying anything, the getSourceItems() method returns a set of values which are then displayed.
public class FXMLDocumentController implements Initializable {
#FXML
private Label label;
#FXML
private Button button;
#FXML
private JFXListView<Label> listv;
#FXML
private ListSelectionView<Label> abc;
#FXML
private void handleButtonAction(ActionEvent event) {
System.out.println("You clicked me!");
label.setText("Hello World!");
}
#Override
public void initialize(URL url, ResourceBundle rb) {
}
#FXML
private void handleToggle(MouseEvent event) {
ObservableList<Label> users = FXCollections.observableArrayList();
abc.setSourceHeader(new Label("Present"));
abc.setTargetHeader(new Label("Absent"));
for (int i=0; i<4;i++)
{
users.add(new Label("Name "+i));
}
abc.setSourceItems(users);
abc.setDisable(false);
for (int i=0; i<4;i++)
{
Label k = new Label("Hello"+i);
listv.getItems().add(k);
}
}
#FXML
private void handlenewNOde(MouseEvent event) {
ObservableList<Label> users1 =abc.getSourceItems();
System.out.println("Source items");
for(int i =0; i<users1.size(); i++)
{
Label k=users1.get(i);
System.out.println(k.getText());
}
System.out.println("Target items");
ObservableList<Label> users12 =abc.getTargetItems();
for(int i =0; i<users12.size(); i++)
{
Label k=users12.get(i);
System.out.println(k.getText());
}
}
}
.fxml :
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXListView?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import org.controlsfx.control.ListSelectionView?>
<AnchorPane id="AnchorPane" prefHeight="680.0" prefWidth="914.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.141" fx:controller="listselectionviewtryout.FXMLDocumentController">
<children>
<Button fx:id="button" layoutX="14.0" layoutY="21.0" onAction="#handleButtonAction" text="Click Me!" />
<Label fx:id="label" layoutX="17.0" layoutY="54.0" minHeight="16" minWidth="69" />
<JFXListView fx:id="listv" layoutX="131.0" layoutY="35.0" prefHeight="237.0" prefWidth="75.0" />
<JFXButton layoutX="413.0" layoutY="58.0" onMouseClicked="#handleToggle" text="Toggle Extension" />
<JFXButton layoutX="445.0" layoutY="134.0" onMouseClicked="#handlenewNOde" text="new Node" />
<ListSelectionView fx:id="abc" layoutX="226.0" layoutY="262.0" />
</children>
</AnchorPane>
Ignore the JFXListView.
Output:
Source items
Name 0
Name 1
Name 2
Name 3
Target items
Should
abc.setSourceItems(users);
be
abc.getSourceItems().addAll(users);