title: How to make Scrollbar of scroll pane make movable automatically with the cursor as we press TAB Button on keyboard?
body: <p>I have following code. After executing following code It shows an JFrame containg A JInternalFrame which has a JScrollPane This JScrollPane has a JPanel has many input controls. As the size of JPanel is larger because of many input controls than the size of JInternalFrame So I it Scrollable.</p>
  
  <pre><code>import java.awt.Dimension;
  import javax.swing.JDesktopPane;
  import javax.swing.JFrame;
  import javax.swing.JInternalFrame;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.JTextField;
  
  public class InterfaceDesign {
  
      public static void main(String args[]) {
          InterfaceDesign id = new InterfaceDesign();
          id.getPnlProjectDetail("My Project");
      }
  
      public void getPnlProjectDetail(String strProjectName) {
          JPanel pnlPjDetail = new JPanel();
          JScrollPane scrPjDetail;
          pnlPjDetail.setLayout(null);
          pnlPjDetail.setBounds(0, 0, 400, 400);
          JFrame frmtest = new JFrame();
          JInternalFrame interFrame = new JInternalFrame();
          interFrame.setBounds(0, 0, 280, 180);
  
          frmtest.setBounds(1, 1, 300, 200);
          pnlPjDetail.setPreferredSize(new Dimension(400, 400));
  
          JLabel lblFirstName = new JLabel("First Name");
          JLabel lblLastName = new JLabel("Last Name");
          JLabel lblAddress = new JLabel("Address");
          JLabel lblCity = new JLabel("City");
          JLabel lblZipCode = new JLabel("Zip Code");
          JLabel lblPhone = new JLabel("Phone");
          JLabel lblEmailID = new JLabel("Emain Id");
  
          JTextField tfFirstName = new JTextField();
          JTextField tfLastName = new JTextField();
          JTextField tfAddress = new JTextField();
          JTextField tfCity = new JTextField();
          JTextField tfZipCode = new JTextField();
          JTextField tfPhone = new JTextField();
          JTextField tfEmailID = new JTextField();
  
          lblFirstName.setBounds(25, 55, 85, 20);
          tfFirstName.setBounds(25, 85, 85, 20);
          pnlPjDetail.add(lblFirstName);
          pnlPjDetail.add(tfFirstName);
  
          lblLastName.setBounds(25, 115, 85, 20);
          tfLastName.setBounds(25, 145, 85, 20);
          pnlPjDetail.add(lblLastName);
          pnlPjDetail.add(tfLastName);
  
          lblAddress.setBounds(25, 175, 85, 20);
          tfAddress.setBounds(25, 205, 85, 20);
          pnlPjDetail.add(lblAddress);
          pnlPjDetail.add(tfAddress);
  
          lblCity.setBounds(25, 235, 85, 20);
          tfCity.setBounds(25, 265, 85, 20);
          pnlPjDetail.add(lblCity);
          pnlPjDetail.add(tfCity);
  
          lblZipCode.setBounds(25, 295, 85, 20);
          tfZipCode.setBounds(25, 325, 85, 20);
          pnlPjDetail.add(lblZipCode);
          pnlPjDetail.add(tfZipCode);
  
          lblPhone.setBounds(25, 355, 85, 20);
          tfPhone.setBounds(25, 385, 85, 20);
          pnlPjDetail.add(lblPhone);
          pnlPjDetail.add(tfPhone);
  
          lblEmailID.setBounds(25, 415, 85, 20);
          tfEmailID.setBounds(25, 445, 85, 20);
          pnlPjDetail.add(lblEmailID);
          pnlPjDetail.add(tfEmailID);
  
          scrPjDetail = new JScrollPane(pnlPjDetail);
  
          scrPjDetail.setAutoscrolls(true);
  
          //frmtest.setContentPane(scrProjectDetail);
          interFrame.setContentPane(scrPjDetail);
          JDesktopPane dpane = new JDesktopPane();
          interFrame.setVisible(true);
          dpane.add(interFrame);
  
          //frmtest.getLayeredPane().add(interFrame);
          frmtest.setContentPane(dpane);
          //frmtest.add(scrProjectDetail);
          frmtest.setVisible(true);
          frmtest.setResizable(false);
          frmtest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          //return pnlPjDetail;
      }
  }
  </code></pre>
  
  <p>I need your guidance in solving following problems/doubts</p>
  
  <ol>
  <li>As we press TAB Button on keyboard the cursor moves from one text box to another but the ScrollBar (here vertical scroll bar) does not moves automatically with the cursor as cursor moves to the lower input fields So how to make the scrollbar move itself with the cursor as it moves either downwards or upperwards?</li>
  <li>As this is a demo code is it possible to add the two JscrollPane in JInterNalFrame side by Side?</li>
  <li>Is it necessary to user JDesktopPane to add JInternalFrame in to JFrame? i.e. is it true that we can not add JInternalFrame as follows
  <code>&lt;JFrame&gt;.getContentPane.add(&lt;JInternalFrame&gt;);</code></li>
  </ol>