dwurity> Hi I am developing an applet application, and placed an
dwurity> Image,when a button(zoom In) click ,I have to perform the
dwurity> zoom In function .....
dwurity> How can I do that...
e.g. using a JPanel, override paintComponent:
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g.create();
AffineTransform transform = new AffineTransform();
Insets insets = getInsets();
transform.translate(insets.left, insets.top);
// Implement a getScale() method which returns your current scale
double scale = getScale();
// Assumes you want to scale equally on x and y axes
transform.scale(scale, scale);
g2.transform(transform);
// Implement a getImage() method which returns your current Image
Image image = getImage();
if (null != image)
{
g2.drawImage(image, 0, 0, this);
}
g2.dispose();
}
That's one way to do it - then just hook up your button to a setter to
a method setScale(double scale) which changes the scale value.