Problem

How to load an Image


Solution

If you have a table column 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()));
   }
}

Published in Mon, 13 December 2010 11:37