Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2004

Tip: Looking for answers? Try searching our database.

JScrollPane + JPanel + JTable

Thread view: 
Stefan Richter - 15 Dec 2004 12:39 GMT
Hi, I have this problem:
I want to create a window that has / is a scrollPane and on this
scrollpane you should see various tables that are inside of other
scrollpanes and on top of each of those tables a little JPanel as
description should be shown.

I tried various things and looked up for example codes, but so far I
could find anything helpfull and didn't succeed myself.

Here is what I got so far ( I know it must be totally screwed, but oh
well...).

First of all, I am dynamically creating and filling the tables, then I
am doing the Labels and then I am creating a Jpanel, adding all
Scrollpanels with the tables inside tables and labels and then I am
adding this JPanel to my big Scrollpanel.
( It's a bit different, I changed the names and just copied parts of
the code, so the real coordinates would be more exact).

               label1.setFont(new java.awt.Font("Verdana", Font.BOLD,
12));
               label1.setText("label1");
               label1.setBounds(new Rectangle(20, 40, 300, 21));
               cp.add(label1);
              label2.setFont(new java.awt.Font("Verdana", Font.BOLD,
12));
               label2.setText("label2");
               label2.setBounds(new Rectangle(20, 60, 300, 21));
               cp.add(label2);
              label3.setFont(new java.awt.Font("Verdana", Font.BOLD,
12));
               label3.setText("label3");
               label3.setBounds(new Rectangle(20, 80, 300, 21));
               cp.add(label3);

               table1 = otherClass.getTable();
               table2 = otherClass.getTable();
               table3 = otherClass.getTable();
               
               table1 .setEnabled(true);
               table1 .setDragEnabled(true);
               table1 .setBounds(60, 10, 200, 200);
               
               table2 .setEnabled(true);
               table2 .setDragEnabled(true);
               table2 .setBounds(60, 300, 200, 200);

               table3 .setEnabled(true);
               table3 .setDragEnabled(true);
               table3 .setBounds(60, 500, 200, 200);

               scrollPane1 = new JScrollPane(table1 );
               scrollPane1 .setBounds(new Rectangle(20, 170, 500,
70));
             
               scrollPane2 = new JScrollPane(table2 );
               scrollPane2 .setBounds(new Rectangle(20, 270, 500,
70));

              scrollPane3 = new JScrollPane(table3 );
               scrollPane3 .setBounds(new Rectangle(20, 370, 500,
70));

 
       tableScrollPane= new JScrollPane();
       tableScrollPane.setBounds(new Rectangle(0, 0, 400, 400));

       tablePanel.setBounds(new Rectangle(0,0,400,4000));
       tableScrollPane.getViewport().add(tablePanel);
       
       tablePanel.add(label1);
       tablePanel.add(label2);
       tablePanel.add(label3);

       tablePanel.add(scrollPane1);
       tablePanel.add(scrollPane2);
       tablePanel.add(scrollPane3);
       
       container.add(tableScrollPane);
       tableScrollPane.setViewportView(tablePanel);
               
With this code I see a scrollpanel but the tables are not under each
other but come in side by side... that's really weird!

Can you help me out?

Thanks,

Stefan
Thomas Weidenfeller - 15 Dec 2004 14:22 GMT
> Hi, I have this problem:
> I want to create a window that has / is a scrollPane and on this
> scrollpane you should see various tables that are inside of other
> scrollpanes and on top of each of those tables a little JPanel as
> description should be shown.

(a) You are creating a usability nightmare - I pity your users

(b) You are not using layout managers

> ( It's a bit different, I changed the names and just copied parts of
> the code, so the real coordinates would be more exact).

(c) You are just providing code fragments, making it hard for anyone to
play with your example.

In a nutshell: Don't do it. If you really have to do it, at least do it
in a clean portable way, and if you ask for help, make it easy for us to
provide help. For all this, and much more, see the link below.

/Thomas
Signature

ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.