• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 sunke
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!!!
please go through my post and help me!!!
Thank you..
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
jyothi sunke
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This puts your table into a scroll pane.
 
reply
    Bookmark Topic Watch Topic
  • New Topic