### UI App (jSwing)

To note is that Oracle removed support for UI apps on the ARM Java in newer versions of Java.
The latest known version supporting UI apps on ARM boards, is Java 1.8.0_6.
Which means going forward, UI apps are not supported on ARM boards.
Workaround
A possible workaround is to build a B4J Non-UI with Java jSwing Framework Components.
The jSwing components are defined in the Inline Java section.
Communication between the Inline Java code and the B4J code is via raiseevents.
These "B4J Non-UI UI" application also run under Windows. So when developing under Windows, then no issue to test.
Recommend to read the jSwing Tutorial: http://docs.oracle.com/javase/tutorial/uiswing/
Example HelloWorld
'Non-UI application (console / server application)
Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
End Region
`Sub Process_Globals
Private nativeMe As JavaObject = Me
End Sub`
`Sub AppStart (Args() As String)
'Run the inline java dialog
nativeMe.RunMethod("HelloDialog", Array("Hello World"))
'Do not forget to close properly
ExitApplication2(0)
End Sub`
'Show a swing message dialog in a B4J nonui app
If JAVA
import javax.swing.JOptionPane;
public static void HelloDialog(String msg) {
JOptionPane.showMessageDialog( null, msg );
}
End If
Example Button raising an BA Event
Inline Java Code:
...
JPanel southPanel = new JPanel();
southPanel.setLayout(new GridLayout(0,1));
//Button Send
JButton buttonSend = new JButton("Send Message");
buttonSend.setBackground(Color.GREEN);
buttonSend.setToolTipText("Click to sent the message.");
buttonSend.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
//System.out.println("buttonSend clicked.");
//Raise the ba event by calling the sub sendmessage with paramater text from a textarea
ba.raiseEvent(this, "sendmessage", textareaMessageSend.getText());
}
});
southPanel.add(buttonSend, BorderLayout.SOUTH);
...
B4J Code: SendMessage
`Sub SendMessage(msg As String)
Log("SendMessage :: Start")
Log(msg)
...
Log("SendMessage :: End")
End Sub`

Changed: 2018-06-07 09:21, Category: Raspberry Pi Sample Projects, File: T6C238M1747.htm, ID: 1747