juanfd
IS-IT--Management
- Jan 21, 2004
- 45
Hello I've been trying to creat a mini Paint application but so far all i can do is load an image, display it and apply some effects on it.
I need to be able to paint circles, rectangles, etc over it and then save it wih the new stroke i've drawn.
I'm using DisplayJAI in order to display the image, but as I try to override the mouseClicked, mouseEntered, etc. methods, they just don't do anything. After step by step debugging I found that the programm never goes through these lines of code, no matter what. Maybe I'm missing soething. any help is greatly appreciated.
The code I am using:
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.io.*;
import javax.media.jai.*;
import javax.swing.*;
import com.sun.media.jai.widget.DisplayJAI;
public class imageDisplay extends DisplayJAI {
public imageDisplay(PlanarImage image){
this.set(image);
}
public void mouseClicked(MouseEvent me){
System.out.println("hola clic");
}
public void mouseEntered(MouseEvent me){
System.out.println("hola enter");
}
public void mouseExited(MouseEvent me){
System.out.println("hola exit");
}
public void mousePressed(MouseEvent me){
System.out.println("hola press");
}
public void mouseReleased(MouseEvent me){
System.out.println("hola release");
}
public void mouseDragged(MouseEvent me){
System.out.println("hola dragg");
}
public void mouseMoved(MouseEvent me){
System.out.println("hola move");
}
}
and to display the image on a JScrollPane:
display = new imageDisplay(image);
imagePanel.add(new JScrollPane(display),BorderLayout.CENTER);
imagePanel.validate();
thanks a lot!
I need to be able to paint circles, rectangles, etc over it and then save it wih the new stroke i've drawn.
I'm using DisplayJAI in order to display the image, but as I try to override the mouseClicked, mouseEntered, etc. methods, they just don't do anything. After step by step debugging I found that the programm never goes through these lines of code, no matter what. Maybe I'm missing soething. any help is greatly appreciated.
The code I am using:
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.io.*;
import javax.media.jai.*;
import javax.swing.*;
import com.sun.media.jai.widget.DisplayJAI;
public class imageDisplay extends DisplayJAI {
public imageDisplay(PlanarImage image){
this.set(image);
}
public void mouseClicked(MouseEvent me){
System.out.println("hola clic");
}
public void mouseEntered(MouseEvent me){
System.out.println("hola enter");
}
public void mouseExited(MouseEvent me){
System.out.println("hola exit");
}
public void mousePressed(MouseEvent me){
System.out.println("hola press");
}
public void mouseReleased(MouseEvent me){
System.out.println("hola release");
}
public void mouseDragged(MouseEvent me){
System.out.println("hola dragg");
}
public void mouseMoved(MouseEvent me){
System.out.println("hola move");
}
}
and to display the image on a JScrollPane:
display = new imageDisplay(image);
imagePanel.add(new JScrollPane(display),BorderLayout.CENTER);
imagePanel.validate();
thanks a lot!