B4J Code Snippet TableView: Adding tooltips to column headers

Discussion in 'B4J Code Snippets' started by Mashiane, Aug 20, 2018.

  1. Mashiane

    Mashiane Expert Licensed User


    This is no magic really, some time ago there was a post here about adding fontawesome buttons to headers, so I included it on my snippets, here too.

    I have realized something, my table has abbreviations and I sometimes forget what they even mean. Lol.


    So me things, there is already a button added, why not also include a tooltip. The tableView setGraphic method comes handy to do that, however it does not extend the column width. So I had to read the column width and then increase it by the button icon width..

    'set an icon for a column header
    Sub TableViewSetColumnHeaderToolTip(idxPos As int, Tooltip As String)
    If idxPos = -1 Then Return
    Dim cWidth As Double = TV.GetColumnWidth(idxPos)
    Dim btn As Button
        btn.PrefWidth = 
        btn.PrefHeight = 
        btn.Enabled = 
        btn.MouseCursor = fx.Cursors.HAND
        btn.Font = awesome
        btn.Text = 
        btn.TooltipText = Tooltip
        CSSUtils.SetBackgroundColor(btn, fx.Colors.Transparent)
    'expand the with
        TV.SetColumnWidth(idxPos,cWidth + 32)
    End Sub

    'set the column graphic
    private Sub TableViewSetColumnGraphicOnly(Index As Int, xNode As Node)
    Dim jo As JavaObject = TV
    Dim column As JavaObject = jo.RunMethodJO("getColumns"Null).RunMethod("get"Array(Index))
    End Sub
    So now, even if I forget, I can just hover on the Q mark and know what the column is about... ;)
    amaxco, inakigarm, Erel and 2 others like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice