Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
jyothi sunke
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hello!!!
please go through my post and help me!!!
Thank you..
 
jay denzel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • 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
 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Stephane Weber
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • 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
 
Mag Hoehme
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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