Ok, I want to ask something. I want to be able to create a JFrame, to put inside the JFrame a JScrollPane, which ViewPort contains another JPanel. The JPanel does nothing else than to paint a rectangle. But I add a JToolBar in the JFrame with one Button for Rotating. When I click the button the rectangle in the JPanel gets rotated. So far so good. But when I move the Scrolls of the JScrollPane the Rectangle moves as well and I want it to stay on the position on the JPanel where I've put it on the beginning.
Here is my code for a better understandment.

Java Code:
public class MainFrame extends JFrame implements ActionListener {
	
	private AffineTransform af;
	
	public MainFrame(){
		super();
		MainPanel mp = new MainPanel(this);
		JButton rotate = new JButton("Rotate");
		rotate.setActionCommand("rotate");
		rotate.addActionListener(this);
		JToolBar jtb = new JToolBar();
		jtb.add(rotate);
		JScrollPane jsp = new JScrollPane();
		jsp.getViewport().add(mp,BorderLayout.CENTER);
		this.add(jsp);
		this.add(jtb,BorderLayout.PAGE_START);
		af = new AffineTransform();
	}
	
	public static void main(String args[]){
		MainFrame mf = new MainFrame();
		mf.setSize(400, 400);
		mf.setVisible(true);
	}
	
	public void setRotate(double angle, int x, int y){
		af.rotate(angle, x, y);
	}
	
	public AffineTransform getAf(){
		return this.af;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getActionCommand().equals("rotate")){
			this.setRotate(30, 100, 100);
		}
		
	}

	public void setAf(AffineTransform af) {
		this.af = af;
	}

}

public class MainPanel extends JPanel {
	
	private MainFrame mf;
	
	public MainPanel(MainFrame mf){
		this.mf = mf;
		this.setPreferredSize(new Dimension(300,300));
	}
	
	public void paint(Graphics g){
		Graphics2D g2 = (Graphics2D)g;
		g2.setTransform(mf.getAf());
		g.drawRect(50, 50, 100, 100);
		this.mf.repaint();
	}

}