Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

dustinkredmond/JavaFXTableMapper

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaFXTableMapper

Simply use ObjectTableView in place of JavaFX's TableView and all of the work is handled for you.

Example:

Model class:

public class Test {

  private int id;
  private String name;
  private String city;
  private String country;
  
  // annotate with HiddenField to skip rendering in TableView
  @HiddenField
  private String internalId;
  
  // annotate with ColumnName to provide custom name for the TableView
  @ColumnName(name = "Pretty Column Name")
  private String someThingLongAndUnintuitive;
  
  // getters/setters/constructor here
  // a findAll() method implementation
}

JavaFX Application:

import com.jfxdev.ObjectTableView; // our only class

ObservableList<Test> myObjects = Test.findAll();

// ObjectTableView takes care of mapping the object to a TableView
ObjectTableView<Test> table = new ObjectTableView<>(myObjects);

// use below constructor if we don't have our data yet, but still want the TableView
// ObjectTableView<Test> table = new ObjectTableView<>(Test.class); 
    
// Name multiple columns via Map
HashMap<String,String> columnNames = new HashMap<>();
columnNames.put("id", "T1_ID");
columnNames.put("name", "NAME");
table.applyColumnNameMapping(columnNames);

// or name them one at a time (a bit slower)
table.renameColumn("city", "City");

If we add the above ObjectTableView to a scene, we should end up with the following:

table

That's all folks, everything is handled in the com.jfxdev.ObjectTableView class. Feel free to use it in your own code or fork the repo.

About

Eliminates boilerplate code associated with creating and filling JavaFX TableViews.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.