B4J Question Pane with dimension of a A4 sheet

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
how i can add a pane to run time or by designer
with the dimensions of an A4 sheet (210x297 mm)?
It is necessary to have the dimensions of a single pixel
of the screen?
How do I get this?
Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I use the following ( on my display it matches an A4 page to less than .5mm)

This is a cut down example - it uses javaobject library
B4X:
Sub AppStart (Form1 As Form, Args() As String)
 MainForm = Form1
 MainForm.SetFormStyle("UNDECORATED")
 MainForm.Show
 asJO(Me).RunMethod("makeA4Page",Array(MainForm))
End Sub
Sub asJO(o As JavaObject)As JavaObject
 Return o
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
 Return True
End Sub
#if java
import javafx.stage.Stage;
public static void makeA4Page(anywheresoftware.b4j.objects.Form s){
 Double dpi = javafx.stage.Screen.getPrimary().getDpi();
 Double dpmm = dpi/25.4;
 s.setWindowHeight(297 * dpmm);
 s.setWindowWidth(210 * dpmm);
}
#End If
 
Upvote 0
Top