title: How to use JScrollPane with JTabbedPane?
body: <pre><code>public RoteLearnerTabbedPanePage() throws IOException, SAXException, ErrorCondition
          {
              JFrame frm=new JFrame();
  
  
              tabbedPane=new JTabbedPane();
              Document doc=rx.readXmlFile();
              if(!rx.validateClassIds())
              {
                  JOptionPane.showMessageDialog(panel1,"Check Xml file. Duplicate 'Class Ids' are present","Error", JOptionPane.ERROR_MESSAGE);
                  System.exit(0); 
              }
              if(!rx.validateAttributeIds())
              {
                  JOptionPane.showMessageDialog(panel1,"Check Xml file. Duplicate 'Attribute Ids' are present","Error", JOptionPane.ERROR_MESSAGE);
                  System.exit(0);     
              }
              if(!rx.isValidMainClass())
              {
                  JOptionPane.showMessageDialog(panel1,"Check Xml File. Main-class declaration for one of the domain classes seems invalid","Error", JOptionPane.ERROR_MESSAGE);
                  System.exit(0);
              }
              Hashtable&lt;String,String&gt; mainclasnames=rx.getMainClassNames(doc, doc.getChildNodes());
  
              Set&lt;XmlClass&gt; guiAttrVals=rx.getGuiAttributeValues(doc, doc.getChildNodes());
              int j=0;
              int i=0;
              Iterator&lt;Entry&lt;String, String&gt;&gt; mainclass_it = mainclasnames.entrySet().iterator();
              while(mainclass_it.hasNext())
              {
  
                  Entry&lt;String, String&gt; classDet = mainclass_it.next();
                  String classname = classDet.getValue();
                  final Hashtable&lt;JLabel,JTextField&gt; uiParams=new Hashtable&lt;JLabel,JTextField&gt;();
                  JButton buttonLearn = new JButton("Learn");
                  panel1= new JPanel();
                  panel1.setLayout(new BoxLayout(panel1, BoxLayout.PAGE_AXIS));
                  transientPanel=new JPanel(new GridBagLayout());
  
                  // Create a sequential group for the vertical axis.
                  nonTransientPanel=new JPanel(new GridBagLayout());
                  JScrollPane scroll1 = new JScrollPane(panel1);
                  tabbedPane.add(scroll1);
                  // Create a sequential group for the horizontal axis.
  
                  GridBagConstraints constraints = new GridBagConstraints();
                  GridBagConstraints nontranconstraints = new GridBagConstraints();
                  Iterator&lt;XmlClass&gt; guiItr=guiAttrVals.iterator();
                  while(guiItr.hasNext())
                  {       
                      XmlClass xmlclasss=guiItr.next();
                      if(classname.equals(xmlclasss.getName()))
                      {
                          Set&lt;XmlAttributes&gt; xmlAttrs=xmlclasss.getAttributes();
                          Iterator&lt;XmlAttributes&gt; xmlattrItr=xmlAttrs.iterator();
                          while(xmlattrItr.hasNext())
                          {
  
                              XmlAttributes xa=xmlattrItr.next(); 
                              String attrname=xa.getName();
                              String isTransient=xa.isTransientAttr();
                              if(isTransient.equals("false"))
                              {
                                  nontranconstraints.insets = new Insets(10, 10, 10, 10);
                                  nontranconstraints.gridx = 0;
                                  nontranconstraints.gridy = i;
                                  JLabel name = new JLabel(attrname);
                                  if(primaryKeys.contains(name.getText()))
                                  {
                                      name.setForeground(Color.RED);
                                  }
                                  else
                                  {
                                      name.setForeground(Color.BLUE);
                                  }
                                  panel1.add((nonTransientPanel), BorderLayout.CENTER);
                                  nonTransientPanel.setPreferredSize(new Dimension(200,100));
                                  nonTransientPanel.add(name,nontranconstraints);
                                  nontranconstraints.gridx = 1;
                                  JTextField value = new JTextField(20);
                                  nonTransientPanel.add(value,nontranconstraints);
                                  i++;
                                  uiParams.put(name, value);
                              }
                              else
                              {
                                  constraints.insets = new Insets(10, 10, 10, 10);
                                  constraints.gridx = 0;
                                  constraints.gridy = j;
                                  JLabel name = new JLabel(attrname);
                                  if(primaryKeys.contains(name.getText()))
                                  {
                                      name.setForeground(Color.RED);
                                  }
                                  else
                                  {
                                      name.setForeground(Color.BLUE);
                                  }
                                  transientPanel.setPreferredSize(new Dimension(200,100));
                                  transientPanel.add(name,constraints);
                                  constraints.gridx = 1;
                                  JTextField value = new JTextField(20);
                                  transientPanel.add(value,constraints);
                                  j++;
                                  uiParams.put(name, value);
                              }
                          }
  
                          nonTransientPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Non Transient Attributes"));
  
                          panel1.add(nonTransientPanel);
                          panel1.setPreferredSize(new Dimension(300,300));
                          transientPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Transient Attributes"));
                          panel1.add(transientPanel);         
                          constraints.gridx = 0;
                          constraints.gridy = ++j;
                          //constraints.gridwidth = 2;
                          constraints.anchor = GridBagConstraints.SOUTH;
                          //buttons.add(buttonLearn,constraints);
                          buttonLearn.setAlignmentX(Component.CENTER_ALIGNMENT);
                          panel1.add(buttonLearn);
                          //panel1.setLayout(fl);
                          tabbedPane.addTab(classname, panel1);
                      }
                  }
  </code></pre>
  
  <p>this is my code. I am really new to this. I don't know exactly how to use JScrollPane with JTabbedPane. I am using JtabbedPane inside which there is one outer JPanel which holds 3 inner jPanels viz. transientPanel, nontransient and buttons panel.</p>