Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Help with using TableView and FXML  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please tell me how to adapt this code for TableView JavaFX in FXML? I have placed the function code in Main.



I can’t figure out how to add this to my FXML file.

 
Marshal
Posts: 5980
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrej Kopp, and Welcome to the Ranch!

About your post: don't post to a very old thread with a new problem.  Create a new thread.  I've done that for you this time.
 
Knute Snortum
Marshal
Posts: 5980
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the original code from the old thread for reference:
 
Knute Snortum
Marshal
Posts: 5980
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Andrej Kopp wrote:I can’t figure out how to add this to my FXML file.


If this code is static, then you can edit the FXML file with a text editor or Scenebuilder from Gluon.

If this code in dynamic, then don't worry about adding to the FXML file, just add to the scene graphic you want to change, for instance personOperationsView or rootLayout.

Am I getting what you want to do?
 
Andrej Kopp
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:Hi Andrej Kopp, and Welcome to the Ranch!

About your post: don't post to a very old thread with a new problem.  Create a new thread.  I've done that for you this time.



Hi Knute Snortum, thank you!

Knute Snortum wrote:

Andrej Kopp wrote:I can’t figure out how to add this to my FXML file.


If this code is static, then you can edit the FXML file with a text editor or Scenebuilder from Gluon.

If this code in dynamic, then don't worry about adding to the FXML file, just add to the scene graphic you want to change, for instance personOperationsView or rootLayout.

Am I getting what you want to do?



I already use Scene Builder. I want to integrate checkboxes into a tableview. In order to select Select All, all checkboxes from the table were selected as in the screenshot.



My Project on GitHub: https://github.com/SequelONE/UsersApp
 
Knute Snortum
Marshal
Posts: 5980
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cloned your github project but a) I can't see that you're handling any checkboxes in PresonController.java and b) I can't get PersonView.fxml to display in my SceneBuilder (version 11.0.0, Ubuntu).
 
Andrej Kopp
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:I cloned your github project but a) I can't see that you're handling any checkboxes in PresonController.java and b) I can't get PersonView.fxml to display in my SceneBuilder (version 11.0.0, Ubuntu).



a) I'm new to javaFX, but it seemed right for me to do it in the controller CheckBoxTableCellFactory.

b) The problem is this import.



If you comment this out when using Scene Build, you can open the FXML file.
 
Knute Snortum
Marshal
Posts: 5980
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have a CellFactory in a different class than the controller?  I don't think you can do that.
 
Andrej Kopp
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:Why do you have a CellFactory in a different class than the controller?  I don't think you can do that.





The selected checkbox in the TableView column selects all checkboxes when necessary, so that all checkboxes are not selected by clicking on the top checkbox. Please tell me how to fix?

Person


PersonController



FXML:

 
Knute Snortum
Marshal
Posts: 5980
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think all you need to do is remove some code from selectAllBoxes in PersonController:
 
Andrej Kopp
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:I think all you need to do is remove some code from selectAllBoxes in PersonController:




As practice has shown the problem in this line. What can be done?

 
Knute Snortum
Marshal
Posts: 5980
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like the problem is in the Person class.  You need to instantiate the boolean property, and it shouldn't be static.
 
Andrej Kopp
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:It looks like the problem is in the Person class.  You need to instantiate the boolean property, and it shouldn't be static.



Thank you. How when you click on the top checkbox, select all the checkboxes from the column?



This code catches the click event of the top column. In addition to selecting all the checkboxes, I need to catch the IP of these records in order to later remove them from the database MariaDB.
 
Andrej Kopp
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


With this code all checkboxes began to get out. It remains to figure out how to get a list of ID for removal from the database.
 
Knute Snortum
Marshal
Posts: 5980
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would assume just by calling getPersonId()
 
Andrej Kopp
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:I would assume just by calling getPersonId()



Thank you. And how to catch the event by clicking on the random checkbox with the output of his ID?

 
Knute Snortum
Marshal
Posts: 5980
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Selecting all and deleting from the database should be two different operations. You would click on the header checkbox to select all, then you press a delete button to delete from the database. I don't think you need anything to detect checking the checkbox of an individual Person.  The delete button would have a setOnAction() method where you do the deleting:
 
Andrej Kopp
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:Selecting all and deleting from the database should be two different operations. You would click on the header checkbox to select all, then you press a delete button to delete from the database. I don't think you need anything to detect checking the checkbox of an individual Person.  The delete button would have a setOnAction() method where you do the deleting:



When I click on the checkbox, I want to count the number of checkboxes with a value of true.

 
Andrej Kopp
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Andrej Kopp wrote:

Knute Snortum wrote:Selecting all and deleting from the database should be two different operations. You would click on the header checkbox to select all, then you press a delete button to delete from the database. I don't think you need anything to detect checking the checkbox of an individual Person.  The delete button would have a setOnAction() method where you do the deleting:



When I click on the checkbox, I want to count the number of checkboxes with a value of true.



It looks like something turned out, but I do not understand why, when clicking on the same checkbox, the number of duplicate output duplicates id. And displays 3, 4, 5, 6 copies each. And if after compilation to click on the very first checkbox with a record, then the console will output a double of the first record.
 
Knute Snortum
Marshal
Posts: 5980
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, about your posts: don't automatically quote the entire previous post, only the amount necessary to provide context.  In your last two posts it wasn't necessary to quote anything.  The context was already there.

About the code you posted: I don't know of any reason to add a listener inside of a cell factory.  I think you will need an updateDeleteButton() method that you call when you select a row or select all.
 
Andrej Kopp
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very match! Everything worked as it should!
 
Knute Snortum
Marshal
Posts: 5980
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure.
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!