This code puts a JTable into a JFrame (sole component of the whole UI):
JFrame frame = new JFrame( "Title");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTable table = appender.createTable();
JScrollPane scrollPane = new JScrollPane(table);
table.setFillsViewportHeight(true);
frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
I also have some code to set the preferred size of the columns.
Nothing fancy. When the UI opens, the table takes up the whole view and I have no scroll bars. The combined preferred widths of the columns need more horizontal space than the windows is wide. Despite of that, there is no horizontal scroll bar and the columns are too narrow.
What do I have to do that
- The columns are still resizable by the user
- The current width is respected? I.e. when I change the width of one column, the width of the other columns should not change.