Login  Register

Image update

Posted by Blandine Chanteloup on Aug 01, 2005; 10:52am
URL: http://imagej.273.s1.nabble.com/Image-update-tp3705123.html

Hello,

I'm trying to move a form (a rectangle for example) drawn upon an image
using the mouse.

The code is :

public class JFrame_TestImageJ extends javax.swing.JFrame implements
MouseListener {
        private ij.IJ myImageJ;
        private ij.ImagePlus myImagePlus;
        private ij.process.ImageProcessor myImageProcessor;
        private ij.gui.ImageCanvas myImageCanvas;

        private void initGUI() {
                myImageJ = new ij.IJ();
                myImageJ.open("image.bmp");
                myImagePlus = myImageJ.getImage();
                setSize(myImagePlus.getWidth(), myImagePlus.getHeight());
                myImageProcessor = myImagePlus.getProcessor();
                myImageProcessor.setColor(Color.red);
                myImageCanvas = new ij.gui.ImageCanvas(myImagePlus);
                this.add(myImageCanvas);
                myImageCanvas.addMouseListener(this);
}

public void mousePressed(MouseEvent evt) {
                myImageProcessor.drawRect(evt.getX(), evt.getY(), 150, 150);
                myImagePlus.setProcessor(null,myImageProcessor);
}


The problem is the update of the form draw.
When I press the mouse, the rectangle doesn't appear.
Is anybody can tell me what's wrong ???

When I resize the frame, the rectangle then appears !!!!

Thanks ...