when i zoom JPanel it zooms and its components zooms but it converts to painted component not the component its self which i can't control it or type on it if it JTextField and the original component stay at its size and location as shown in picture
and this is my code
i make the panel which i want to zoom here in this class
public class designPanel extends JPanel{
public double zoomFactor = 1;
public boolean zoomer = true;
public AffineTransform at;
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (zoomer == true) {
at = g2.getTransform();
at.scale(zoomFactor, zoomFactor);
zoomer = false;
}
g2.transform(at);
}
public void setZoomFactor(double factor){
if(factor<this.zoomFactor){
this.zoomFactor=this.zoomFactor/1.1;
}
else{
this.zoomFactor=factor;
}
this.zoomer=true;
}
public double getZoomFactor() {
return zoomFactor;
}
}
and then zoom in and out this panel by mouse wheel in this code
design_gridPanel.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (e.getWheelRotation() < 0) {
design_gridPanel.setZoomFactor(1.1 * design_gridPanel.getZoomFactor());
design_gridPanel.revalidate();
design_gridPanel.repaint();
}
if (e.getWheelRotation() > 0) {
design_gridPanel.setZoomFactor(design_gridPanel.getZoomFactor() / 1.1);
design_gridPanel.revalidate();
design_gridPanel.repaint();
}
}});