I have made a GUI JTable which displays a database. I have one problem with sizing.
How can I make it so that the columns of the JTable will fill the JScrollPane but if there are a lot of columns in one table for example then it would just keep them default size and let them scroll.
Basically..
If one of the SQL tables don't fill the JTable and don't need scrolling then I want the columns of that JTable to be made bigger so they do fit.
If the SQL JTable does need scrolling then I just want it to be left like that so it needs scrolling.
This is the code I have for making the JTable:
JPanel panel1 = new JPanel();
JTable table = new JTable(){
private static final long serialVersionUID = 1L;
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
JScrollPane stable = new JScrollPane (table);
stable.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
stable.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
panel1.add(stable);