Quote Originally Posted by alex.j.r View Post
First things first, your right about the huge chunk of code. I didn't read SSCCE. but now I have and will learn for next time.
Good man.

Second, overriding getPreferredScrollableViewportSize() wasn't the problem. You could put it in a /* */
and it wouldn't make a difference at all.
Oh, OK. I'm sorry about that - we must be talking at cross purposes. I thought you were talking about not getting scroll bars displayed correctly.

I previously created an SSCCE from your original code, and found that, as expected, the scroll bars only appeared correctly when the override was removed.

When I run the modified code you just posted, the scroll bars still don't appear correctly until the override is removed (it's clearer when ATMFrame is made resizeable).

So you may have fixed the problem you were posting about (which I misinterpreted), but there still seems to be a problem with the scroll bars of the scroll pane, for which my previous answer still stands.

I'd be curious to know if your experience is different (i.e. whether you get scroll bars correctly displayed), because overriding getPreferredScrollableViewportSize() will interfere with scroll bar display on all the systems I've used.

If you have a spare moment, please try this minimal demo, with and without the override of getPreferredScrollableViewportSize():
Code:
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;

public class ScrollTest extends JFrame {

    public static void main(String[] args) {
        new ScrollTest();
    }

    public ScrollTest() throws HeadlessException {
        super("Scroll Test");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        String[] tableHeaders = { "Column 1", "Column 2", "Column 3",
                "Column 4", "Column 5", "Column 6" };

        DefaultTableModel model = new DefaultTableModel(tableHeaders, 40);
        JTable table = new JTable(model) {
			public Dimension getPreferredScrollableViewportSize() {
				return getPreferredSize();
			}
        };

        JScrollPane scroll = new JScrollPane(table);
        JPanel panel = new JPanel();
        panel.add(scroll);
        add(panel);
        setSize(600, 400);
        pack();
        setVisible(true);
    }
}
The outcome of any serious research can only be to make two questions grow where only one grew before...
T. Veblen