jlbovo
Nov 13th, 2006, 02:34 PM
Hello, I am still wokring on the same project and I have come into yet another problem I'd like to learn to fix now.
The desgin should be as follows : I need to pass x-y coordiantes to a Vector, so i can store them. Left clicking would draw a circle and get the coordinates of the point clicked. The Vector is there so if I were to right click I could erase the last stored coordinates.
Here's what I was given to work with...
class ImagePanel extends JPanel {
private BufferedImage currentbufimg; // this is the real image associated with each ImagePanel object.
private int panelID; // identifier for each ImagePanel.
private UIDDemo1 parent; // parent object.
private Vector features; // features to be selected by the users.
As you can see the Vector is named features.... and a paint component will call the drawfeatures object....and then...
public void paintComponent(Graphics g){
super.paintComponent(g);
if(currentbufimg != null)
g.drawImage(currentbufimg,0,0,this);
if(panelID == 1 || panelID == 2)
drawFeatures(g);
if(panelID == 3) {
drawDisplacement(g);
}
}
...i'm with left this little bit of code to figure out how i would be able to get those variables passed to the Vector.
public void drawFeatures(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setColor(Color.white);
// draw circles and save to Vector.
I already have a mouse event handler to capture the x-y coordniates when the mouse is clicked. I just need some type of guidence on how i could go abouts doing this...I understand the add etc of the Vector soem what, but will i need another mouse event to get thsi started.
Again any guidence will be very helpful, for i am tryin my best to understand and learn thsi Java. Thansk again - Justin
The desgin should be as follows : I need to pass x-y coordiantes to a Vector, so i can store them. Left clicking would draw a circle and get the coordinates of the point clicked. The Vector is there so if I were to right click I could erase the last stored coordinates.
Here's what I was given to work with...
class ImagePanel extends JPanel {
private BufferedImage currentbufimg; // this is the real image associated with each ImagePanel object.
private int panelID; // identifier for each ImagePanel.
private UIDDemo1 parent; // parent object.
private Vector features; // features to be selected by the users.
As you can see the Vector is named features.... and a paint component will call the drawfeatures object....and then...
public void paintComponent(Graphics g){
super.paintComponent(g);
if(currentbufimg != null)
g.drawImage(currentbufimg,0,0,this);
if(panelID == 1 || panelID == 2)
drawFeatures(g);
if(panelID == 3) {
drawDisplacement(g);
}
}
...i'm with left this little bit of code to figure out how i would be able to get those variables passed to the Vector.
public void drawFeatures(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setColor(Color.white);
// draw circles and save to Vector.
I already have a mouse event handler to capture the x-y coordniates when the mouse is clicked. I just need some type of guidence on how i could go abouts doing this...I understand the add etc of the Vector soem what, but will i need another mouse event to get thsi started.
Again any guidence will be very helpful, for i am tryin my best to understand and learn thsi Java. Thansk again - Justin