'---------------------------------
' Setup terminal and screen layers
'---------------------------------
Terminal = CreateTerminal
Screen = CreateScreen(Terminal)
Screen.RunMethod("startScreen", Null)
Screen.RunMethod("clear", Null)
TextGraphics = Screen.RunMethod("newTextGraphics", Null)
'--------------------------------
' Create Create panel to hold components
'--------------------------------
gridlayout = CreateGridLayout(2)
pannello = CreatePanel
pannello.RunMethod("setLayoutManager",Array As Object(gridlayout))
Dim lbl1 As JavaObject = CreateLabel("Num.1:")
Dim tBox1 As JavaObject = CreateTextBox(CreateTerminalSize(20,1))
Dim lbl2 As JavaObject = CreateLabel("Num.2:")
Dim tBox2 As JavaObject = CreateTextBox(CreateTerminalSize(20,1))
Dim spazio_vuoto As JavaObject = CreateEmptySpace(CreateTerminalSize(0,0))
' Creazione e gestione del primo pulsante
Dim runnable1 As JavaObject = CreateRunnable("Button1_Click")
Dim button1 As JavaObject
button1.InitializeNewInstance("com.googlecode.lanterna.gui2.Button", Array("TEST", runnable1))
pannello.RunMethod("addComponent",Array As Object(lbl1))
pannello.RunMethod("addComponent",Array As Object(tBox1))
pannello.RunMethod("addComponent",Array As Object(lbl2))
pannello.RunMethod("addComponent",Array As Object(tBox2))
pannello.RunMethod("addComponent",Array As Object(spazio_vuoto))
pannello.RunMethod("addComponent",Array As Object(button1))
'--------------------------------
' Create window to hold the panel
'--------------------------------
form = CreateBasicWindow'
form.RunMethod("setComponent",Array As Object(pannello))
'SetFullScreenHint(BasicWindow)
'BasicWindow.RunMethod("setHints",Array As Object(WindowHint.GetField("FULL_SCREEN")))
'-------------------------
' Create gui and start gui
'-------------------------
gui = MultiWindowTextGUI(Screen, CreateWindowManager, CreateEmptySpaceTextColor(CreateTextColor("RED"))) 'Colore di sfondo
gui.RunMethod("addWindowAndWait", Array As Object(form))
End Sub
Sub Button1_Click
Log("Button 1 simulated for add 2 numbers")
End Sub
Sub CreateRunnable(MethodName As String) As Object
Dim jo As JavaObject
jo.InitializeNewInstance("java.lang.Object", Null)
Return jo.CreateEvent("java.lang.Runnable", MethodName, False)
End Sub
Sub CreateTerminalSize(colonne As Int,righe As Int) As JavaObject
Dim componente As JavaObject
Return componente.InitializeNewInstance("com.googlecode.lanterna.TerminalSize",Array As Object(colonne,righe))
End Sub
Sub CreateButton(etichetta As String) As JavaObject
Dim componente As JavaObject
Return componente.InitializeNewInstance("com.googlecode.lanterna.gui2.Button",Array As Object(etichetta))
End Sub
Sub CreateButtonRunnable(etichetta As String,evento As String) As JavaObject
Dim componente As JavaObject
Return componente.InitializeNewInstance("com.googlecode.lanterna.gui2.Button",Array As Object(etichetta,evento))
End Sub
Sub CreateLabel(etichetta As String) As JavaObject
Dim componente As JavaObject
Return componente.InitializeNewInstance("com.googlecode.lanterna.gui2.Label",Array As Object(etichetta))
End Sub
Sub CreateTextBox(par_terminal_size As JavaObject) As JavaObject
Dim componente As JavaObject
Return componente.InitializeNewInstance("com.googlecode.lanterna.gui2.TextBox",Array As Object(par_terminal_size))
End Sub
Sub CreateGridLayout(colonne As Int) As JavaObject
Dim gl As JavaObject
Return gl.InitializeNewInstance("com.googlecode.lanterna.gui2.GridLayout",Array As Object(colonne))
End Sub
Sub CreatePanel As JavaObject
Dim pnl As JavaObject
Return pnl.InitializeNewInstance("com.googlecode.lanterna.gui2.Panel", Null)
End Sub
Sub CreateBasicWindow As JavaObject
Dim window As JavaObject
Return window.InitializeNewInstance("com.googlecode.lanterna.gui2.BasicWindow", Null)
End Sub
Sub CreateEmptySpace(par_terminal_size As JavaObject) As JavaObject
Dim componente As JavaObject
Return componente.InitializeNewInstance("com.googlecode.lanterna.gui2.EmptySpace",Array As Object(par_terminal_size))
End Sub
Sub CreateEmptySpaceTextColor(par_text_color As JavaObject) As JavaObject
Dim componente As JavaObject
Return componente.InitializeNewInstance("com.googlecode.lanterna.gui2.EmptySpace",Array As Object(par_text_color))
End Sub
Sub CreateTextColor(color As String) As JavaObject
Dim textColorFactory As JavaObject
textColorFactory.InitializeStatic("com.googlecode.lanterna.TextColor$Factory")
' Use the factory to create a TextColor
Dim tc As JavaObject
tc = textColorFactory.RunMethod("fromString", Array As Object(color))
Return tc
End Sub
Sub WindowHint As JavaObject
Dim wh As JavaObject
Return wh.InitializeStatic("com.googlecode.lanterna.gui2.Window.Hint")
End Sub
Sub MultiWindowTextGUI(scr As Object,windowmanager As Object,bg As Object) As JavaObject
Dim gui As JavaObject
Return gui.InitializeNewInstance("com.googlecode.lanterna.gui2.MultiWindowTextGUI", Array As Object(scr,windowmanager,bg))
End Sub
Sub CreateWindowManager As JavaObject
Dim wm As JavaObject
Return wm.InitializeNewInstance("com.googlecode.lanterna.gui2.DefaultWindowManager", Null)
End Sub
Sub CreateTerminal As JavaObject
Dim factory As JavaObject
Return factory.InitializeNewInstance("com.googlecode.lanterna.terminal.DefaultTerminalFactory", Null).RunMethod("createTerminal", Null)
End Sub
Sub CreateScreen(Term As Object) As JavaObject
Dim s As JavaObject
Return s.InitializeNewInstance("com.googlecode.lanterna.screen.TerminalScreen", Array(Term))
End Sub
Sub SetCharacter(Char1 As Char, Column As Int, Row As Int)
TextGraphics.RunMethod("setCharacter", Array(Column, Row, Char1))
End Sub
Public Sub SetString (s As String, Column As Int, Row As Int)
TextGraphics.RunMethod("putString", Array(Column, Row, s))
End Sub
Sub Refresh
Screen.RunMethod("refresh", Null)
End Sub