title: Scaling JScrollPane with picture
body: <p>I'm new to java and swing:). I need help with scaling JScrollPane when I scaling picture whit method scale :
  Graphics2D g2 = (Graphics2D) g;
  g2.scale(1, 0.3);//I need to scale my picture
  When I apply scaling to an image, the JScrollPane does not scale. It's in the  &quot;protected void paintComponent(Graphics g)&quot; method. How can I do that - scaling picture together with IScrollPane. Is't possible? Maybe there is something better for creating java images.
  Thank you for any help.</p>
  <pre><code>import java.awt.Dimension;
  import java.awt.EventQueue;
  import java.awt.Graphics;
  import java.awt.Graphics2D;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.UIManager;
  import javax.swing.UnsupportedLookAndFeelException;
  
  public class Test extends JPanel {  
    public static void main(String... args) {
          EventQueue.invokeLater(new Runnable() {
              @Override
              public void run() {
                  try {
                      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
                      ex.printStackTrace();
                  }
                  Test test = new Test();
                  JFrame frame = new JFrame();
                  JScrollPane scrollPane = new JScrollPane(test);
                  frame.add(scrollPane);
                  frame.pack();
                  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                  frame.setVisible(true);
              }
          });
      }
  
      @Override
      public Dimension getPreferredSize() {
          return new Dimension(3000, 3000);
      }
  
      @Override
      protected void paintComponent(Graphics g) {
          super.paintComponent(g);
          Graphics2D g2 = (Graphics2D) g;
          g2.scale(1, 0.3);//I need to scale my picture
          g2.drawLine(30, 30, 30, 3000);
          g2.drawLine(30, 400, 500, 3000);
      }
  }
  </code></pre>