Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

why it could not work properly

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
    Bookmark Topic Watch Topic
  • New Topic