You have to use “mDataScrollPane.setView(tableView)”. Even though ScrollPane is a container, it doesn’t support adding children, and so the single scrollable element has to be added as the “view” of the ScrollPane.
~Roger From: Damir Dezeljin [mailto:[email protected]] Sent: Friday, October 18, 2013 9:47 AM To: user Subject: Re: How to apply styles to TableView rows On the way to solving the initial task I bumped in another problem. I can't find the way to display a TableView in a ScrollPane with id="mDataScrollPane" from the Java code. Unfortunately I can't find an example that doesn't use a BXML file. Here is my code: ---- window.bxml ---- <dockable:ContentWindow title="%mainAppTitle" maximized="true" bxml:id="mainWindow" xmlns:bxml="http://pivot.apache.org/bxml" xmlns:content="org.apache.pivot.wtk.content" xmlns:dockable="si.dezo.ewn" xmlns:collections="org.apache.pivot.collections" xmlns="org.apache.pivot.wtk"> ... <content> <Border xmlns="org.apache.pivot.wtk" styles="{padding:6}"> <TablePane> <columns> <TablePane.Column width="1*"/> </columns> <TablePane.Row height="1*"> <Border styles="{color:10}"> <ScrollPane bxml:id="mDataScrollPane" horizontalScrollBarPolicy="fill" preferredHeight="240" verticalScrollBarPolicy="fill_to_capacity"> </ScrollPane> </Border> </TablePane.Row> </TablePane> </Border> </content> </dockable:ContentWindow> ---- ---- ContentWindow.java ---- package si.dezo.ewn; ... public class ContentWindow extends Window implements Bindable { @BXML private ScrollPane mDataScrollPane; public ContentWindow() { return; } @Override public void initialize(Map<String, Object> namespace, URL location, Resources resources) { Map<String, String> map = new HashMap<String, String>(); map.put("nation", "SLO"); map.put("gold", "20"); List<Map<String, String>> tableData = new ArrayList<Map<String, String>>(); tableData.add(map); TableView tableView = new TableView(tableData); ColumnSequence columns = tableView.getColumns(); columns.add(new Column("nation", "Država", 100)); columns.add(new Column("gold", "Zlato", 100)); TableViewHeader header = new TableViewHeader(); header.setTableView(tableView); mDataScrollPane.add(tableView); return; } } ---- What am I doing wrong? Thanks, Damir
