Ok seems like no answers except the newbie one. Here is my code
the only problem with it is when I drag the frame may be because of coordinate casting (some elements in getLocation and getPoint are double needed to be casted to int) or image processings inability of keeping up with drag, some parts of the image becomes disoriented after some drags. Take a look at the code you will understand it.
public void mouseDragged(MouseEvent e) {
VistaLook.this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
Point endPoint = e.getPoint();
double diffx = endPoint.getX()- startPoint.getX();
double diffy = endPoint.getY()- startPoint.getY();
((ImageJFrame)frame).doDrag(diffx,diffy);
}
public void setImage(int x,int y,boolean init){
try {
Rectangle frameRect = new Rectangle();
frameRect.setLocation(x,y);
frameRect.setSize(this.getSize());
if(init == true)
jLabel1.setIcon(new ImageIcon(new java.awt.Robot().createScreenCapture(frameRect)));
else
jLabel1.setIcon(new ImageIcon(combineImages(x,y)));
} catch (AWTException ex) {
Logger.getLogger("global").log(Level.SEVERE, null, ex);
}
}
private BufferedImage combineImages(int x,int y){
java.awt.image.BufferedImage newImage = new java.awt.image.BufferedImage(this.getWidth(),
this.getHeight(),
java.awt.image.BufferedImage.TYPE_INT_RGB);
java.awt.image.BufferedImage currentImage = (BufferedImage) ((ImageIcon) jLabel1.getIcon()).getImage();
Graphics2D g = newImage.createGraphics();
if(x>=0&&y>=0)
g.drawImage(currentImage.getSubimage(x, y, currentImage.getWidth()-x, currentImage.getHeight()-y),0,0,null);
else if(x>=0 &&y<0)
g.drawImage(currentImage.getSubimage(x, 0, currentImage.getWidth()-x, currentImage.getHeight()+y),0,-y,null);
else if(x<0 && y>=0)
g.drawImage(currentImage.getSubimage(0, y, currentImage.getWidth()+x, currentImage.getHeight()-y),-x,0,null);
else if (x<0 && y<0)
g.drawImage(currentImage.getSubimage(0, 0, currentImage.getWidth()+x, currentImage.getHeight()+y),-x,-y,null);
else;
try{
if(x!=0)
if(x>0){
java.awt.Rectangle rectX = new java.awt.Rectangle(this.getX()+this.getWidth(),
this.getY(), x,
this.getHeight());
java.awt.image.BufferedImage imageX = new java.awt.Robot().createScreenCapture(rectX);
g.drawImage(imageX, currentImage.getWidth()-x, 0, null);
} else{
java.awt.Rectangle rectX = new java.awt.Rectangle(this.getX()+x,
this.getY(), -x,
this.getHeight());
java.awt.image.BufferedImage imageX = new java.awt.Robot().createScreenCapture(rectX);
g.drawImage(imageX, 0, 0, null);
}
if(y!=0)
if(y>0){
java.awt.Rectangle rectY = new java.awt.Rectangle(this.getX(),
this.getY()+this.getHeight(), this.getWidth(),
y);
java.awt.image.BufferedImage imageY = new java.awt.Robot().createScreenCapture(rectY);
g.drawImage(imageY, 0, currentImage.getHeight()-y, null);
} else{
java.awt.Rectangle rectY = new java.awt.Rectangle(this.getX(),
this.getY()+y, this.getWidth(),
-y);
java.awt.image.BufferedImage imageY = new java.awt.Robot().createScreenCapture(rectY);
g.drawImage(imageY, 0, 0, null);
}
} catch (AWTException ex) {
Logger.getLogger("global").log(Level.SEVERE, null, ex);
}
return newImage;
}
> He probably means that the answer from ONJava.com is
> for newbies...
Thats exactly what I meant sorry for misunderstanding. I concider myself a newbie why people take it really offensive.
And the answer to my question has to do with my being a newbie and forget that application is getting static pictures while draging and putting 3 pictures together which 1 of them is from the ealier position. That was the answer and all duke oscar(stars) goes to me!!!!
Thanks to everyone ...
It's offensive when you have more than 10 years of experience.
But I see it was just a misunderstanding.
Anyway updating the image while you drag the window is easy.
The problematic part is what you do when other application change position or your application is covered by another application and then gaines back the focus.
Yes thats the area where JNI kicks in. Trying to sort it with the jniwrapper or will build my own dll. But I know jniwrapper is not very effective in transparency and stuff and usage causes flicks on the window. Still trying.
I just hope that one of the smart guyz will come with a better idea than mine.