jscrollpane problem

Hi
  I'm not sure if this is possible..i'm looping through a table and creating 2 labels and a JTextArea with a scrollpane on the fly...ll these controls are on a subpanel

I need to then push all these controls on a scrollpanel..so the controls created dynamically on a scrollpane as i need to show the controls in a small area space..so the users would scroll to look at th controls created dynamically from the database..the controls show dynamically but the final scrollpane doesnt show..what am i doing wrong


 while (rs.next()) {
           
           
            l_startTime = rs.getString(1);
            l_heading = rs.getString(2);
            l_news = rs.getString(3);
           
           
         rowindex=rowindex+1;
         
         
   
         JLabel label = new javax.swing.JLabel();
         new CRMFormControls(null,null,"label",JPanel5,10,50+x,100, 19, new java.awt.Font("Arial", 1, 12), new java.awt.Color(248,67,112),l_startTime,label,null,null,null,null);
         label.setBackground(new java.awt.Color(186,196,227));
         JLabel label1 = new javax.swing.JLabel();
         new CRMFormControls(null,null,"label",JPanel5,200,50+x,600, 19, new java.awt.Font("Arial", 1, 12), new java.awt.Color(248,67,112),l_heading,label1,null,null,null,null);  
         label1.setBackground(new java.awt.Color(186,196,227));
         
         x=x+30;

         JTextArea JNews = new javax.swing.JTextArea();
         new CRMFormControls(null,JNews,"jtextarea",JPanel5,200,50+x,600, 50, new java.awt.Font("Arial", 1, 10), new    java.awt.Color(150,150,150),"Decision Makers",null,null,null,null,null);
         JNews.setForeground(new java.awt.Color(0,0,0));
         JNews.setBackground(new java.awt.Color(186,196,227));
         JNews.setLineWrap(true);
         JNews.setText(l_news);
         JScrollPane scrollPane12 = new JScrollPane(JNews);
         scrollPane12.setBounds(200,50+x,600, 50);
         JPanel5.add(scrollPane12);
         
         x=x+60;
       
        }
       
       
        scrollPane1.setBounds(10,50,600, 300);
        JPanel3.add(scrollPane1);
        tabbedPaneNews = new JTabbedPane();
        tabbedPaneNews.setBounds(10,50 , 600, 300);
       
        JPanel3.add(tabbedPaneNews);
        tabbedPaneNews.addTab("Calendar",  scrollPane1);
        tabbedPaneNews.setBackground(new java.awt.Color(186,196,227));
        tabbedPaneNews.setForeground(new java.awt.Color(150,150,150));
        tabbedPaneNews.setFont(new java.awt.Font("Arial", 1, 12));
        JPanel5.setBounds(10,50 , 600, 300);

        JPanel1.add(JPanel3);

       

       
       
trance12Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

trance12Author Commented:
sorry, code was messy there

x=0;

JScrollPane scrollPane1 = new JScrollPane(JPanel5);

while (rs.next()) {
           
           
            l_startTime = rs.getString(1);
            l_heading = rs.getString(2);
            l_news = rs.getString(3);
           
           
         rowindex=rowindex+1;
         
         
   
         JLabel label = new javax.swing.JLabel();
         label.setbounds(10,50+x,100, 19);
         JPanel5.add(label);

         JLabel label1 = new javax.swing.JLabel();
         label1.setbounds(200,50+x,100, 19);
         JPanel5.add(label1);
         
         x=x+30;

         JTextArea JNews = new javax.swing.JTextArea();
         JNews.setbounds(200,50+x,600, 50);
         JNews.setText(l_news);
         JScrollPane scrollPane12 = new JScrollPane(JNews);
         scrollPane12.setBounds(200,50+x,600, 50);
         JPanel5.add(scrollPane12);
         
         x=x+60;
       
        }
       
       
        scrollPane1.setBounds(10,50,600, 300);
        JPanel3.add(scrollPane1);
        tabbedPaneNews = new JTabbedPane();
        tabbedPaneNews.setBounds(10,50 , 600, 300);
       
        JPanel3.add(tabbedPaneNews);
        tabbedPaneNews.addTab("Calendar",  scrollPane1);
        JPanel5.setBounds(10,50 , 600, 300);

        JPanel1.add(JPanel3);


zzynxSr. Software engineerCommented:
>> the final scrollpane doesnt show
And it's variable name is?
trance12Author Commented:
scrollPane1..its on the first line of my code..
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

trance12Author Commented:
sorry..meant the second posted code..first one was messy
zzynxSr. Software engineerCommented:
I'd like to see the layout used for all your panels
Dejan PažinHead of SW DevelopmentCommented:


You are using setBounds method for positioning your components. That is bad approach in Java, and that is the root of your problems here.

The way you should do it, is to use layout managers, such as BorderLayout, GridLayout and FlowLayout (those are the basic ones).

Read this tutorial: http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dejan PažinHead of SW DevelopmentCommented:

And if you insist on using absolute positioning (i.e. using setBounds) you should be aware that you are using it. That means, you should set layout manager to null on all the components to which you are adding absolute positioned components.

But again, using that is simply bad choice and you will be better of taking a look at the layout managers and using them.
trance12Author Commented:
i have used null layouts for all my panels though..
trance12Author Commented:
actually the scrollpane is showing now..but when i use it to scroll it stops..it doesnt show the botttom border of the scrollpane..is this to do with the fact that i'm adding utems dynamically?
zzynxSr. Software engineerCommented:
>> i have used null layouts for all my panels though..
I also strongly advice you to use one of the common layout managers.
They'll take care of the positioning of your components. That's what they're made for.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.