Cookbook
Load an image PDF Print E-mail

Recipe: How to load an Image

If you have a table field of type Binary/Image linked on a Form with a control named imagePanel1, the code below, activated from a Button, will let the user choose an Image from the local filesystem and load it in the image control.

import javax.swing.*;

selImage(e){
    JFileChooser fc = new JFileChooser();
    int returnVal = fc.showOpenDialog(thisForm);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
          imagePanel1.setImageData(new dataweb.util.datatype.ImageData(fc.getSelectedFile()));
    }
}

Last Updated on Friday, 23 October 2009 14:46