aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Problem with JTable  when no. of records are more than the size of frame!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Problem with JTable  when no. of records are more than the size of frame!!!" Watch "Problem with JTable  when no. of records are more than the size of frame!!!" New topic
Author

Problem with JTable when no. of records are more than the size of frame!!!

jyothi sunke
Ranch Hand

Joined: Sep 11, 2002
Posts: 65
Hi all,
I am experiencing problem with JTable while displaying the results. If records are more than to fit in the size of frame, scrollpane is showing vertical scrollbar. It's fine. But in that situation only one column is occupying the whole frame. I am not able to see the other colums unless I adjust the column headers or by maximizing the frame size. Moreover, scrollpane not showing the Horizontal scrollbar even if I reduce the width of frame.
If the displayed records fit in the size of frame(I mean no need of vertical scrollbar in this case..to dispaly 10 to 15 records), in this case I can see all columns and it is working fine. I am getting problem only when Vertical Scrollbar comes in the frame..
Please help me in this regard.. what might be the reason for this problem?? and did anyone face this problem??
Thanks in advance..
[ October 31, 2002: Message edited by: jyothi sunke ]

jyothi
jyothi sunke
Ranch Hand

Joined: Sep 11, 2002
Posts: 65
Hello!!!
please go through my post and help me!!!
Thank you..
jay denzel
Ranch Hand

Joined: Sep 18, 2002
Posts: 57
hi,
I did the following.
Added this ...
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setSize(600, 300);
this.getContentPane().add(scrollPane, BorderLayout.CENTER);
to my JFrame. Thats all. Works great.
I did not experience such behaviour.
Maybe this helps...
jay
Andrea Gazzarini
Ranch Hand

Joined: Sep 09, 2002
Posts: 125
JTable table = new JTable(new MyDataModel());
JScrollPanel scroller = new JScrollPane();
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// In this way the column header of the table doens't scroll.
scroller.setColumnHeaderView(table.getTableHeader());
scroller.setViewportView(table);
Hope it helps.


Regards,<br />Andrea<br /> <br /><a href="http://www.linkedin.com/in/andreagazzarini" target="_blank" rel="nofollow">Andrea Gazzarini</a><br />Skype ID : gazzax72<br />Google Talk ID : a.gazzarini@gmail.com<br /><a href="http://www.andreagazzarini.blogspot.com" target="_blank" rel="nofollow">My Blog</a>
jyothi sunke
Ranch Hand

Joined: Sep 11, 2002
Posts: 65
Thank you Jay and Andrea..
Are u allowing the user to resize the frame or not??
Ofcourse I am allowing the user to resize the frame..But I just wanted to know. If I set that setResizable property false, will it come in violation of the reqirementS?
Stephane Weber
Ranch Hand

Joined: Mar 07, 2002
Posts: 110
It will not violate the requirements, no. Some people here told they did use the setResizable(false) and succeeded in their exam.
However, the general trends is to allow resizing, as it is more close to reality. No application nowadays forbids resizing. But of course, FBN is just an exercise.
Hope it helps
Stephane
Mag Hoehme
Ranch Hand

Joined: Apr 07, 2002
Posts: 194

This puts your table into a scroll pane.


Mag
 
Don't get me started about those stupid light bulbs.
 
subject: Problem with JTable when no. of records are more than the size of frame!!!