Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Understanding Bounds for JTable and JScrollPane

 
Dennis Putnam
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a problem getting my scrollable JTable set up correctly. My problem is the height of JScrollPane and/or JTable. The bottom part of the scroll bar is not visible within my JFrame. I have played with the height parameter of 'setBounds' for both the JTable and JScrollPane but neither seems to bring the bottom of the scroll bar into view. It seems like the bounds for the scroll pane should do it but I can't get it to effect anything. Can some educate me on what controls what? TIA.
 
Dennis Putnam
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind. I got it and am too embarrassed to say what it was. Sorry.
 
Guillaume Jourdan
Ranch Hand
Posts: 47
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

You must set AutoResizeMode at AUTO_RESIZE_OFF on your JTable.

If you don't do that, the JTable try to resize and ignore the scroll problem even if there is size problem.
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guillaume, what you suggest doesn't affect the stated problem:
The bottom part of the scroll bar is not visible within my JFrame.
I suspect the real issue was attempting absolute placement and sizing using the size of the JFrame instead of that of its contentPane. And if my suspicions are correct, then I have to say: don't use setBounds(...). Use an appropriate layout manager or a combination of them.
 
Guillaume Jourdan
Ranch Hand
Posts: 47
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you try and you give us the result.

Your bottom scrollbar is hide when your JTable is in auto-resize and your JTable is by default in auto-resize.
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the second time: the problem as stated isn't about the "bottom" -- or horizontal - scrollbar. Dennis clearly said that
The bottom part of the scroll bar is not visible within my JFrame.
 
Guillaume Jourdan
Ranch Hand
Posts: 47
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, we understand the sentence differently.

For me, I understand :
The bottom part of the scroll bar is not visible within my JFrame
is not only a piece of horizontal scrollbar. When auto-resize is off, right part of the scrollbar (vertical scrollbar) is visible but not bottom part.



How can I have a JTable in a JScrollPane with horizontal scroll bars?

table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
If autoResizeMode is set differently, the JTable automatically resizes itself to the width of the JScrollPane.

ref : http://www.chka.de/swing/table/faq.html



I have played with the height parameter of 'setBounds' for both the JTable and JScrollPane but neither seems to bring the bottom of the scroll bar into view.


@Dennis : It's possible that I have no understand the question, but for me, Darryl doesn't see the horizontal scrollbar.

@Darryl : Can you give us your code and a printscreen of your problem if I don't understand your problem ?
 
Dennis Putnam
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm kind of surprised that this thread is active since I said the problem was an embarrassing mistake on my part. However, if you two are going to have a debate then I will clarify by saying there is no horizontal scroll bar involved.
 
Guillaume Jourdan
Ranch Hand
Posts: 47
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I have switch @Dennis and @Darryl ;p

Sorry Darryl, you've rigth, this is certainly a layout problem.

A simple setLayout(new BorderLayout(1,1)); on your frame may be suffisant for your case.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic