B4J Question Tooltip font size

rfresh

Well-Known Member
Licensed User
Longtime User
How can I increase the font size of my textfield tooltips?

Thank you...
 

behnam_tr

Active Member
Licensed User
Longtime User
check this
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Yes I did follow the link in post #2.

I get this error: java.lang.RuntimeException: Object should first be initialized (JavaObject).
on line 3 below.

B4X:
Sub SetToolTipFont(N As Control,F As Font)
    Dim JoN As JavaObject = N
    JoN.RunMethodJO("getTooltip",Null).RunMethod("setFont",Array (F))
End Sub


I tried all of the JoN initialize options but (1) I don't know which one I should use and (2) I don't know what arguments to use.

B4X:
    JoN.InitializeContext(???) 'what is the current Activity or Service?
    JoN.InitializeNewInstance(???,???)'what className and Params to use?
    JoN.InitializeStatic(???)'what className to use?
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
If I do that I get this runtime error: java.lang.RuntimeException: Object should first be initialized (JavaObject).

It happens on this line of code:

B4X:
JoN.RunMethodJO("getTooltip",Null).RunMethod("setFont",Array (F))
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
How are you calling the sub SetTooltipFont? You need to pass the correct parameters.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
OK so now we need to work backwards from there. I assume that lblWaypointType is an array of labels. How have you created the array? Have you added labels from the designer or are you adding them in code?

It looks like one or more of them are not initialized, as a quick test you could iterate the array and check:

B4X:
For each L As Label In lblWaypointType
    Log(L.isInitialized)
Next
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Here is the snippet of my code that creates the label array. It's initialized in line 16 and then the call is made in line 21. Runtime error.

After this loop finishes creating the label array, I ran your code for loop and the log shows true for isInitialized.

B4X:
        Dim lblWaypointType(32) As Label

        For i = 0 To waypointCount - 1
        iLeft = 8
        iWidth = 20
        'waypointCount -----------------------------------------------------------
        lblWaypointCount(i).Initialize("Label")
        lblWaypointCount(i).Alignment = "CENTER_RIGHT"
        p.AddNode(lblWaypointCount(i), iLeft, iTop, iWidth, iHeight)
        iLeft = iLeft + 14
        CSSUtils.SetBackgroundColor(lblWaypointCount(i),fx.Colors.White)

        iLeft = 35
        iWidth = 120
        'WaypointType ------------------------------------------------------------
        lblWaypointType(i).Initialize("Label")
        p.AddNode(lblWaypointType(i), iLeft, iTop, iWidth, iHeight)
        iLeft = iLeft + 130
        CSSUtils.SetBackgroundColor(lblWaypointType(i),fx.Colors.LightGray)

        SetToolTipFont(lblWaypointType(i),fx.CreateFont("Arial",16,True,False))


Then, after creating the label arrays, I ran your loop with the following mod and it still gives the same runtime error.

B4X:
    For i = 0 To waypointCount - 1
        Log(lblWaypointType(i).isInitialized)
        If lblWaypointType(i).isInitialized Then
            SetToolTipFont(lblWaypointType(i),fx.CreateFont("Arial",16,True,False))
        End If
    Next
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Ok, the tooltip is not getting initialized when you are creating the label in code, simple enough to fix. Just add:

B4X:
lblWaypointType(i).TooltipText = ""

after the initialize line.
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Yep!! I just finished writing a test program to zip up and attach. I discovered the same thing. My test app was getting the same runtime error and then I added the line to set the tooltip and it worked!!

Thank you very much for your help. You found the solution because you knew what was causing it, I found the soulition because I stumped upon it by accident!!!
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
But... it looks like a new tooltip is created once you change the tooltip text, so either set the tooltip text as you want it initially, or leave the call to SetTooltipFont until after you have set the tooltip text.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I still think the easiest way to do this is as jmon suggested in the linked thread and use CSS. Just set it up once on each form and forget it.
 
Upvote 0
Top