I have to add Zoom In and Zoom Out
functionality to JPanel
, which contains components like JLabel
with ImageIcon
.
I want to Zoom JPanel
with their components appropriately
I tried with following code snippet but it did not work properly.
The JPanel
which is having null
layout and is itself placed inside an Applet
.
I am unsure of the reason as to why it is not working either because of Applet
or something else !!
cPanel
is my JPanel
which contains JLabel
Following code snippet on Zoom Button
click,
it shows blink screen on button click after that as original
Graphics g = cPanel.getGraphics();
Graphics2D g2d = (Graphics2D) g;
AffineTransform savedXForm = g2d.getTransform();
g2d.scale(1.0, 1.0);
g2d.setColor(Color.red);
super.paint(g);
g2d.setTransform(savedXForm);
cPanel.validate();
cPanel.repaint();