B4J Question Printing a layout JFX8Print - mono spaced font

atiaust

Active Member
Licensed User
Longtime User
Hi All,
How do I change the label font to a mono spaced font while adding labels to nodes to a scroll pane for JFX8Print.
Thanks in advance
 

stevel05

Expert
Licensed User
Longtime User
There are several ways to do this depending on how your project is written. It will be easier to give you the correct solution first time if you show your code that is creating the labels, or better still attach a small example project.
 
Upvote 0

atiaust

Active Member
Licensed User
Longtime User
Thank you Steve for your reply.

I am using your example "printing-on-A4-and-letter".
I generate the string for the label in one code block and put it into a global map (main.printData) which is read in and added to the node in the print routine.

Print:
'    Get the number of lines in the report
    Dim num As Int = Main.printData.Size
    Log("Print Lines = "&num)
    If num <= 50 Then    ' 1 page of data to print
        For i = 0 To Main.printData.Size - 1
            Dim La As Label
            La.Initialize("")
            La.Font = fx.CreateFont("mono spaced",12,False,False)   '' this does not work
'
            La.Text = Main.printData.GetValueAt(i) '" Row " & I
            Dim lineColour As Int = Main.lineColours.GetValueAt(i)
            If lineColour = 1 Then
                La.TextColor = fx.Colors.Red
                
            Else
                La.TextColor = fx.Colors.Black
                
            End If       
            MyPane.AddNode(La,0,(i)*30dip,400dip,25dip)'was (i-1)
''            Log("print data("&i&"), "&Main.printData.GetValueAt(i))
            MyPane.PrefHeight=(i+1)*30dip
        Next
    Else        'figure out how many pages are needed
'           
    End If
'

I tried to change the font for the "La" label but I am not sure how to achieve this.

Thanks
 
Upvote 0
Top