I have added jTable inside the jScrollPane as :
public Scenario_One() {
initComponents();
jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
}
private void initComponents() {
.
.
jScrollPane1.setViewportView(jTable1);
.
.
}
The text to displayed in one single row is too large so I had to use horizontal scroll bars. But even after setting the policy to as needed I do not see the horizontal scroll bars. What could be the reason for this ?
Try something like this…
The width of the view port is dictated by the width of the component it contains. For a
JTable, that is determined by the size of the columns and the auto size policy