Gabriel
Gabriel

Reputation: 5723

Stretching out JScrollPane - Java

I have this structure:

<JFrame>
         <JPanel backgroundcolor = "pink">
            <JScrollPane>
                <JTable>!!!Data here !!!</JTable>
            </JScrollPane>
         </JPanel>
</JFrame>

How do i stretch the ScrollPane it to cover the full window without using setSize? This is how it looks like now: alt text http://img22.imageshack.us/img22/8491/17747996.png

Thanks!

Upvotes: 1

Views: 1678

Answers (3)

Gabriel
Gabriel

Reputation: 5723

Mmmph! Nobody offered a simple solution such as using BorderLayout as layout manager for my JScrollpane container!

Upvotes: 1

trashgod
trashgod

Reputation: 205775

Use setPreferredScrollableViewportSize() and a suitable layout.

Edit: You'll also need setFillsViewportHeight(), as discussed in Adding a Table to a Container.

Upvotes: 0

eee
eee

Reputation: 1053

I am not familiar with the XML file format.

If it is coded, you may need to code something like this:

JScrollPane1 = new JScrollPane();
JPanel1.add(JscrollPane1);
JScrollPane1.setBounds(5,29,636,122);

JTable1 = new JTable();    
JPanel1.add(JTable1);
JScrollPane1.setBounds(5,434,553,3097);
JScrollPane1.setViewportView(JTable1);

Upvotes: 0

Related Questions