• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why it could not work properly

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is part of my program,and it is expected to view the special subimage with mouse dragging.
public boolean mouseDrag(MouseEvent e,int x,int y) {
//to veirfy that the mouse is on the image;
if(x>0 && y>height+20 && x<img.getWidth(this) && y<img.getHeight(this)+height+20)
{
if(ini)
ini=false;
centerX=x;
centerY=y-height-20;
if(centerX<width/2)
centerX=width/2;
if(centerX>(size().width-width/2))
centerX=size().width-width/2;
if(centerY<height/2)
centerY=height/2;
if(centerY<(size().height-height/2))
centerY=size().height-height/2;
//show the rectangle subimage centered by (centerX,centerY)
temp=this.createImage(new FilteredImageSource(img.getSource(), new CropImageFilter(centerX-width/2, centerY-height/2, width, height)));
screen=temp;
this.update(this.getGraphics());
}
return true;
}
public void paint(Graphics g) {
g.drawImage(img,0,height+20,this);
g.drawImage(screen,0,0,this);
g.setColor(Color.red);
g.drawRect(0,20+height,img.getWidth(this),size().height-20-height);
g.setColor(Color.black);
g.drawRect(0,0,width,height);
}
For help!
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Porky,
Can't help with your problem, but your user name is not a valid one here at the ranch. We request that you supply a first name + space + last name. Please read the naming convention policy and re-register with an appropriate name.
Regards,
Manfred.
 
reply
    Bookmark Topic Watch Topic
  • New Topic