JavaFX [1.3] – TableView (?)


Yes! TableView or Data-Grid is really important control and must be included in JavaFX. If you are really in hurry and can use JavaFX 1.2, you can use XTableView from JFXtras. They are also working on JavaFX 1.3 complaint JFXtras 0.7. If you want it to be part of official JavaFX version, put more pressure on Jonathan Giles

If both these strategies failed, you can still put together TableView using a group of ListView. All foundation for implementing a scalable TableView is already in place based on Cell API.



For Applet mode, click on above image
For standalone mode

Mean while you can use above TableView implementation. View is constructed using a set of ListView. The data model is direct copy of Swing. So didn’t really put any effort for implementing this…

Try it out and let me know feedback.. Please let Jonathan Giles know all your requirements on TableView, so that it will be complete and will address all your requirements when its released

Advertisements

About Rakesh Menon
-

12 Responses to JavaFX [1.3] – TableView (?)

  1. Pingback: Tweets that mention JavaFX [1.3] – TableView (?) | Java, JavaFX and beyond… -- Topsy.com

  2. Let’s not confuse things by mentioning ‘grid’ 🙂

    The differentiation is that a grid is a layout, a table / tableview is a UI control.

    We have a grid layout as a preview in JavaFX 1.3.

    • Rakesh Menon says:

      Oopz! Some people refer to table as “Grid”, may be because some languages refer to them as “DataGrid”. Anyway I updated it as “Data-Grid”. Hope it helps.. 🙂

  3. Pingback: JavaFX News, Demos and Insight // FX Experience

  4. Pingback: Java desktop links of the week, May 24 | Jonathan Giles

  5. Pingback: JavaFX – Database + Table | Java, JavaFX and beyond…

  6. KN says:

    Hi Rakesh,

    I am trying to use the ‘onMouseClicked’ event of the TableView, but unfortunately I couldn’t fire the actions within the onMouseClicked event, when I click on a random row of the table. Do I miss some code?

    I hope you can give me some hints. Thanks !

    KN

    def table : TableView = TableView {
    layoutInfo: LayoutInfo {
    width: bind table.scene.width
    height: bind (table.scene.height – 40)
    }
    tableModel: tableModel
    onMouseClicked: function(e:MouseEvent) : Void {
    println(“hi!”);
    }
    }

    • Rakesh Menon says:

      Your code looks good. I’m not sure why its not triggering the event, may be a bug.
      For now, you may handle mouse-events in mouseCaptureRect of TableView class.

  7. Lichti says:

    Hi Rakesh,

    I have used parts of your code to access the scroll bars of a set of ListViews simultaneously. Works great thanks!

    Now I have a problem and thought you maybe have an idea…

    When clicking the up/down arrows of a listview’s vScrollbar, the vScroll.value is set. As long as the height of all cells is the same, the difference between the set values is constant (when clicking repeatedly). But as soon as I change the height of one single cell, the steps from click to click have different values.
    So my question: How does the listview calculate the values used from click to click?

    You can see the purpose for this question in my post at the javafx forum:
    http://forums.sun.com/thread.jspa?messageID=11003066&#11003066

    Would be great if you had some time to spare!
    Thanks!

    • Rakesh Menon says:

      The scrollbar values are set as a percentage of total height. Its not absolute value. So the computation may be complicated for variable height scenario. You need to compute the top invisible area and get the percentage of that area w.r.t total height. Set the scrollbar value as this percentage. Hope this helps.

      • Lichti says:

        Hi Rakesh!
        First solving the problem with a workaround (using a ScrollView around the enlarged ListViews – resulting in memory problems), I’m now stuck with this problem again.

        I think you missunderstood my question. Maybe because my explanation was unclear. I know that the values are set as a percentage. But setting the scrollbar to a percentage does not solve my problem (explained in the forum post linked above).

        The point is, that when clicking the up/down arrows, somehow the value/percentage is computed in the way I want it to. So in the end resulting in a constant scroll speed. Or lets say: constant number of pixels scrolled per click.

        I assume, that no matter which height a cell is set, it is treated with the same percentage. Because when clicking the arrows in the range of an enlarged cell, the difference between the set values is much smaller.
        (And so resulting in the different scroll speed behaviour when using the track, which sets the percentage)

        Ideal result for me: constant scroll speed behaviour when using the track

        Maybe you have some time to review once more ..
        thanks!

  8. Karan says:

    Hi
    I needed to add a choicebox as cell in the table. So i modified the following:
    >> Modified TableView.fx as :
    var items : Object[] = []; …..earlier it was var items : String[] = [];

    >>Modified cellFactory() of TableColumn.fx as follows:
    else {
    if (label == null) {
    label = Label { }
    }
    if(tableView.tableModel.getValueAt(cell.index, index) instanceof ChoiceBox){
    cell.node = tableView.tableModel.getValueAt(cell.index, index) as ChoiceBox;
    }else{
    label.text = “{tableView.tableModel.getValueAt(cell.index, index)}”;
    if (cell.node != label) cell.node = label;
    // println(“Cell Index = {cell.index} and index = {index} \n label.text = {tableView.tableModel.getValueAt(cell.index, index)}”);
    }
    }

    Now when i provide a choiceBox in my tree data…the choicebox is rendered in the tree.

    BUT… now I want to access this choicebox.. Suppose the user selects an option in this choicebox, then I want to know what value the choiceBox contains……
    To achieve this I write the code:

    while(tableColumnsCounter < table.tableColumns.size()-1){
    println("table.tableColumns[0].tableColumnView.items.size() = {table.tableColumns[tableColumnsCounter].tableColumnView.items.size()}");
    var itemsCounter = 0;
    while(itemsCounter < table.tableColumns[tableColumnsCounter].tableColumnView.items.size()){
    println("table.tableColumns[tableColumnsCounter].tableColumnView.items[itemsCounter] = {table.tableColumns[tableColumnsCounter].tableColumnView.items[itemsCounter]}");
    if(table.tableColumns[tableColumnsCounter].tableColumnView.items[itemsCounter] instanceof ChoiceBox){
    println("******************Found choiceBox for column: {tableColumnsCounter}");
    println("******************choiceBox value: {(table.tableColumns[tableColumnsCounter].tableColumnView.items[itemsCounter] as ChoiceBox).selectedItem}");
    }
    itemsCounter++;
    }
    tableColumnsCounter++;
    }

    the statement – table.tableColumns[tableColumnsCounter].tableColumnView.items[itemsCounter] instanceof ChoiceBox is never true as everytime a blank string is returned.

    Kindly Help.

    i want to access the choicebox's selected value ..

    Regards

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: