Technical Support
🟢 Online now
Hello 👋

How can we help you today?
Contact on WhatsApp
B4X Store
jdashboardUI / Tables & Data / TableViewUtils
Tables & Data

TableViewUtils

Static helpers for building visual table-cell content

Source
jdashboardUI.b4xlib · Public API only
Store language: en

Tables & Data · jdashboardUI · B4J / JavaFX

TableViewUtils is a static helper module for building visual content intended for table cells. It is not a table and it does not manage data. Its job is to create ready-to-use Views such as labels, checkboxes, buttons, switches, image/text combinations and icon/text combinations.

Highlights

  • StaticCode module: no Initialize required.
  • Creates labels for cells.
  • Creates custom checkboxes with callbacks.
  • Creates custom buttons with callbacks.
  • Creates custom switches.
  • Creates image + text compositions.
  • Creates icon + text compositions.
  • Returns B4XView or Label objects ready to be inserted into table content.

When to use it

Use TableViewUtils when you need reusable visual cell content without depending on a specific JTableview instance.

Dim StatusCell As Label = TableViewUtils.CreateLabel( _
    "Online", _
    "Current status", _
    fx.Colors.Green)

No Initialize required

The module is declared as:

Type=StaticCode

Call it directly:

TableViewUtils.CreateLabel(...)
TableViewUtils.CreateButton(...)

There is no Initialize, DesignerCreateView, AddToParent or Designer Property surface in this module.


CreateLabel

CreateLabel(LabelText As String, ToolTip As String, color As Paint) As Label
Dim Cell As Label = TableViewUtils.CreateLabel( _
    "Available", _
    "Current availability", _
    fx.Colors.Green)

The helper configures text, color, alignment, wrapping and tooltip.


CreateCheckbox

CreateCheckbox(
    Callback As Object,
    EventName As String,
    Tag1 As String,
    text As String,
    textToolTip As String,
    ColorText As Int,
    icon As String,
    IconColor As Int,
    Font As B4XFont,
    checked As Boolean,
    ColorCheck As Int,
    Corner As Int
) As B4XView
Dim Cell As B4XView = TableViewUtils.CreateCheckbox( _
    Me, _
    "Product", _
    "active", _
    "Active", _
    "Enable or disable the product", _
    xui.Color_White, _
    Chr(0xE876), _
    xui.Color_White, _
    xui.CreateMaterialIcons(18), _
    True, _
    0xFF16A34A, _
    6)

Callback:

Private Sub Product_CheckTable(CheckedSender As jCheckbox, Checked As Boolean)
    Log(CheckedSender.Tag)
    Log(Checked)
End Sub

CreateButton

CreateButton(
    Callback As Object,
    EventName As String,
    Tag1 As String,
    text As String,
    FontText As Font,
    IconText As String,
    IconColor As Int,
    FontIcon As Font,
    ColorButton As Int,
    Corner As Int,
    ColumnWidth As Double
) As B4XView
Dim NormalFont As Font = fx.CreateFont("Arial", 12, False, False)
Dim IconFont As Font = fx.CreateFont("FontAwesome", 12, False, False)

Dim Cell As B4XView = TableViewUtils.CreateButton( _
    Me, _
    "Product", _
    "edit", _
    "Edit", _
    NormalFont, _
    Chr(0xF044), _
    xui.Color_White, _
    IconFont, _
    0xFF258A61, _
    6, _
    100dip)

Callback:

Private Sub Product_ButtonTableAction(BtSender As jButton)
    Select BtSender.Tag
        Case "edit"
            Log("Edit record")
    End Select
End Sub

CreateJSwich

The actual public method name in the library is:

CreateJSwich

The documentation preserves that exact spelling.

Dim SwitchCell As B4XView = TableViewUtils.CreateJSwich( _
    Me, _
    "Product", _
    "enabled", _
    "Enabled", _
    "Product state", _
    xui.Color_White, _
    Chr(0xE876), _
    Chr(0xE14C), _
    xui.CreateMaterialIcons(18), _
    True, _
    0xFF16A34A, _
    6)

Current callback behavior

The analyzed implementation routes switch changes to the same callback suffix used by checkboxes:

Private Sub Product_CheckTable(SenderObject As Object, Checked As Boolean)
    Log(Checked)
End Sub

CreateImageAndText

CreateImageAndText(
    text As String,
    textToolTip As String,
    ColorText As Int,
    ImageDir As String,
    ImageFileName As String,
    IconWidth As Int
) As B4XView
Dim Cell As B4XView = TableViewUtils.CreateImageAndText( _
    "Invoice", _
    "Open invoice", _
    xui.Color_White, _
    File.DirAssets, _
    "archivo-pdf.png", _
    24dip)

Internally it uses JImageView and JTextFlow.


CreateTextAndIcon

CreateTextAndIcon(
    text As String,
    textToolTip As String,
    ColorText As Int,
    icon As String,
    IconColor As Int,
    FontIcon As Font
) As B4XView
Dim IconFont As Font = fx.CreateFont("FontAwesome", 14, False, False)

Dim Cell As B4XView = TableViewUtils.CreateTextAndIcon( _
    "Settings", _
    "Open settings", _
    xui.Color_White, _
    Chr(0xF013), _
    0xFF22D3EE, _
    IconFont)

Complete public API

TableViewUtils exposes six public Subs:

  1. CreateLabel
  2. CreateCheckbox
  3. CreateButton
  4. CreateJSwich
  5. CreateImageAndText
  6. CreateTextAndIcon

Public field:

lbl As Label

Callbacks

Checkbox:

EventName_CheckTable(CheckedSender As jCheckbox, Checked As Boolean)

Button:

EventName_ButtonTableAction(BtSender As jButton)

Switch: the current implementation also invokes EventName_CheckTable(Sender, Checked).


Important callback-state note

TableViewUtils stores mCallback and mEventName at module level.

Creating interactive controls with different callback/event configurations can replace those shared values. For predictable behavior, use one callback/EventName pair for TableViewUtils-created controls or use JTableview's instance factories when you need per-instance isolation.


  • JTableview: advanced visual table with its own cell factories.
  • JDataset: binds Views to SQLite fields.