qualcosa del genere?
codice:
import javax.swing.*;
import java.awt.*;
public class longTable extends JFrame {
private JTable tab;
private String[] headers={"uno","due","tre","quattro","cinque","sei","sette","otto","nove","dieci","uno","due","tre","quattro","cinque","sei","sette","otto","nove","dieci"};
private Object[][] elems = new Object[10][20];
public longTable() {
super("tabella a scorrimento orizzontale");
this.setSize(200,200);
this.setResizable(false);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(new JLabel("tabellona"), BorderLayout.NORTH);
for (int i=0; i < 10; i++) {
for (int j=0; j < 20; j++) {
elems[i][j]=new Integer(i*20+j);
}
}
tab = new JTable(elems, headers);
tab.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
JScrollPane sp = new JScrollPane(tab);
sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
this.add(sp, BorderLayout.CENTER);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main (String[] args) {
longTable l = new longTable();
}
}