title: Adding multiple Jtextareas into same JScrollPane
body: <p>I know there are many questions about it but i read all of them. Mostly people prefer adding textareas into a panel and adding this panel into JScrollPane. I tried this but it is not working.</p>
  
  <p>Here is my code.</p>
  
  <p>AppSed Class</p>
  
  <pre><code>package gui;
  
  import javax.swing.SwingUtilities;
  
  public class AppSed {
  
  public static void main(String[] args){
  
  SwingUtilities.invokeLater(new Runnable(){
      public void run(){
  
          new MainFrame();
      }
      });
  }
  }
  </code></pre>
  
  <p>MainFrame Class</p>
  
  <pre><code>package gui;
  
  import java.awt.BorderLayout;
  
  import javax.swing.JFrame;
  import javax.swing.JMenu;
  import javax.swing.JMenuBar;
  import javax.swing.JMenuItem;
  
  public class MainFrame extends JFrame {
  
  private TextPanel textPanel;
  private ToolBar toolBar;
  
  public MainFrame(){
      super("Sed Debugger");
  
      setLayout(new BorderLayout());
  
      textPanel = new TextPanel();
      toolBar = new ToolBar();
      add(textPanel,BorderLayout.CENTER );
      add(toolBar, BorderLayout.NORTH);
  
      setJMenuBar(createMenuBar());
      setSize(1200,800);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setVisible(true);
  }
  public JMenuBar createMenuBar(){
       JMenuBar menuBar = new JMenuBar();
  
       JMenu file = new JMenu("File");
       JMenu debug = new JMenu("Debug");
       JMenu help = new JMenu("Help");
  
       JMenuItem newFile = new JMenuItem("New");
       JMenuItem saveFile = new JMenuItem("Open");
       JMenuItem openFile = new JMenuItem("Save");
       JMenuItem exit = new JMenuItem("Exit");
  
       file.add(newFile);
       file.add(openFile);
       file.add(saveFile);
       file.add(exit);
  
       JMenuItem run = new JMenuItem("Run");
       JMenuItem stop = new JMenuItem("Stop");
       JMenuItem refresh = new JMenuItem("Refresh");
       JMenuItem stepIn = new JMenuItem("Step In");
       JMenuItem stepOut = new JMenuItem("Step Out");
       JMenuItem stepOver = new JMenuItem("Step Over");
       JMenuItem breakPoint = new JMenuItem("New Breakpoint");
  
       debug.add(run);
       debug.add(stop);
       debug.add(refresh);
       debug.add(stepIn);
       debug.add(stepOut);
       debug.add(stepOver);
       debug.add(breakPoint);
  
       JMenuItem commentHelp = new JMenuItem("Comment Help");
       JMenuItem about = new JMenuItem("About");
  
       help.add(commentHelp);
       help.add(about);
  
       menuBar.add(file);
       menuBar.add(debug);
       menuBar.add(help);
  
       return menuBar;
  }
  }
  </code></pre>
  
  <p>TextPanel class</p>
  
  <pre><code>package gui;
  
  import java.awt.Dimension;
  public class TextPanel extends JPanel {
  private InputPane input ; 
  private JScrollPane scrollPane;
  
  public TextPanel(){
  
      setLayout(new GridBagLayout());
  
      input = new InputPane();
      scrollPane = new JScrollPane(input);
  
      Dimension dim = scrollPane.getPreferredSize();
      dim.width = 510;
      dim.height = 290;
      scrollPane.setPreferredSize(dim);
  
      GridBagConstraints gc = new GridBagConstraints();
  
      gc.gridx = 0;
      gc.gridy = 0;
      gc.weightx = 0.25;
  
      add(scrollPane,gc);
  
  }
  }
  </code></pre>
  
  <p>InputPane class</p>
  
  <pre><code>package gui;
  
  import java.awt.BorderLayout...;
  
  
  public class InputPane extends JPanel {
  
  private JTextArea inputText;
  private JTextArea lineNumber;
  private JScrollPane scrollPane;
  
  public InputPane(){
  
      setLayout(new BorderLayout());
  
      Dimension dim = getPreferredSize();
      dim.width  = 500;
      dim.height = 250;
      setPreferredSize(dim);
  
      setBorder(BorderFactory.createTitledBorder("Original File"));
  
      inputText = new JTextArea();
      lineNumber = new JTextArea();
  
      Dimension dimInput = getPreferredSize();
      dimInput.width = 440;
      dimInput.height = 250;
      inputText.setPreferredSize(dimInput);
  
      Dimension lineDim = getPreferredSize();
      lineDim.width = 50;
      lineDim.height = 250;
      lineNumber.setPreferredSize(lineDim);
      lineNumber.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 2,             Color.gray));
  
      add(inputText,BorderLayout.EAST);
      add(lineNumber,BorderLayout.WEST);
  
  }
  </code></pre>