Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Show
Dim iv As ImageView
iv.Initialize("")
iv.SetImage(asJO(Me).RunMethod("loadImage",Array("file:///c:/temp/marbles.tif")))
MainForm.RootPane.AddNode(iv,10,10,300,300)
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.embed.swing.SwingFXUtils;
import javafx.scene.image.Image;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.net.*;
import java.io.*;
public static Image loadImage(String file)throws MalformedURLException,IOException{
BufferedImage bufferedImage = ImageIO.read(new URL(file));
Image image = SwingFXUtils.toFXImage(bufferedImage, null);
return image;
}
#End If
Fehler in Zeile: 42
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:613)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
at b4j.example.main.start(main.java:44)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
...
Dim iv As ImageView
iv.Initialize("")
Log(asJO(Me))
iv.SetImage(asJO(Me).RunMethod("loadImage",Array("file:///C:/test/CCF100420160009.tif")))
RechnungenForm.RootPane.AddNode(iv,10,10,300,300)
End Sub
Sub asJO(o As JavaObject)As JavaObject
Return o
End Sub
#if java
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.image.Image;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.net.*;
import java.io.*;
public static Image loadImage(String file)throws MalformedURLException,IOException{
BufferedImage bufferedImage = ImageIO.read(new URL(file));
Image image = SwingFXUtils.toFXImage(bufferedImage, null);
return image;
}
#End If
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
File.Copy(File.DirAssets,"CCF100420160009.tif",File.DirApp,"CCF100420160009.tif")
ImageView1.SetImage(LoadTiff(File.DirApp,"CCF100420160009.tif"))
End Sub
Public Sub LoadTiff(FileDir As String,FileName As String) As Image
Dim BuffImg As JavaObject
Dim ImageIO As JavaObject
Dim SwingFXUtils As JavaObject
ImageIO.InitializeStatic("javax.imageio.ImageIO")
SwingFXUtils.InitializeStatic("javafx.embed.swing.SwingFXUtils")
BuffImg = ImageIO.RunMethod("read",Array(File.Openinput(FileDir,FileName)))
Log(BuffImg)
Return SwingFXUtils.RunMethod("toFXImage",Array(BuffImg,Null))
End Sub