Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Set size of JTable inside a JScrollPane

Reply
Thread Tools

Set size of JTable inside a JScrollPane

 
 
Allan Valeriano
Guest
Posts: n/a
 
      06-15-2007
Hi,

I'm inserting a JTable into a JScrollPane which is inserted inside a
JPanel. I'd like to set the size of this JScrollPane to be the same as
the JPanel, so it will show a blank space between the end of my JTable
and the end of my JScrollPane.
I've tryed something like:

table.setPreferredScrollableViewportSize(panel.get Size());

but is not working as I wanted. On this picture, there is a grey space
between the end of the table and the end of the window:
http://java.sun.com/docs/books/tutor...RenderDemo.png

This is because the JScrollPane resizes itself, to fit the size of the
table, but I want it not to resize like that if the table is smaller
then the Panel, so there will be a blank space between the last table
row and the end of the JScrollPane and not between the end of the
JScrollPane and the end of the window.

Does anybody knows how can I do that?

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      06-16-2007
Allan Valeriano wrote:
...
>...show a blank space between the end of my JTable
>and the end of my JScrollPane.
>I've tryed something like:


Please do not wast your time, and our bandwidth,
describing 'something like' the code, input or output.
SSCCE's* and copy/pasted input and output are 1000%
more useful.

* <http://www.physci.org/codes/sscce.html>

>table.setPreferredScrollableViewportSize(panel.ge tSize());
>
>but is not working as I wanted.


What layouts are you using? (considers) No, answer
that in your SSCCE.

>..On this picture, there is a grey space
>between the end of the table and the end of the window:
>http://java.sun.com/docs/books/tutor...RenderDemo.png


I see a white space when I run the code in Java 6..
<http://java.sun.com/docs/books/tutor...enderDemo.java
>


You did try running that code, didn't you? It seems to
behave exactly as you describe you want it to. (Except
the color is white).

>This is because the JScrollPane resizes itself, to fit the size of the
>table, but I want it not to resize like that if the table is smaller
>then the Panel, so there will be a blank space between the last table
>row and the end of the JScrollPane and not between the end of the
>JScrollPane and the end of the window.
>
>Does anybody knows how can I do that?


Well.. you could use the above linked code, that works,
or change it one line at a time to your needs, and post
the result of the first change that stops acting as you
expect.

(I suspect it is the layouts - or lack of them - that
are used in the code. But only the code will tell
the tale.)

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200706/1

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Jscrollpane and jtable yashiro Java 2 05-17-2008 11:52 AM
JTable and JScrollPane helmut.teichmann@opb.de Java 3 07-19-2007 12:35 PM
Putting a JTable inside a JTable cell? Tivo Escobar Java 1 04-12-2007 11:09 AM
Integreating the JScrollPane to JTable Happy Day Java 5 08-17-2005 06:56 AM
Can I nest a JEditorPane inside a JScrollPane inside a JPanel? Mike Java 5 12-02-2003 01:45 PM



Advertisments