我正在编写一个基本的Java应用程序,该应用程序允许用户将有关个人的详细信息插入SQLite数据库。我将Eclipse SWT用于GUI。
Eclipse SWT定义了Image(org.eclipse.swt.graphics.Image)类型,用于在GUI中显示图像。
我试图让用户浏览文件系统,选择一个图像,然后将该图像插入数据库。我还希望能够从数据库中检索该图像并将其显示在GUI中。
一切都非常简单,但对于我的一生,我无法使其正常工作!我也进行了很多搜索,似乎无法找到解决方案。
我正在使用Java开发人员专用的Eclipse IDE(3.6)sqlite-jdbc-3.7.2.jar和JDK 1.6.0_22。
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;
import java.sql.*;
/***********************************************************************/
/*** Tests reading and writing SWT Images from an SQLite Database ***/
/***********************************************************************/
public class ImageTest {
Shell shell;
//Variables to store the current values when editing
private Canvas personPhoto;
private Image personImage;
private int personID = 1;
private double photoWidth = 100;
private double photoHeight = 100;
//Database connection and statement variables
private …Run Code Online (Sandbox Code Playgroud)