Hi,
In my example I put a JTable on a JFrame. I also put a JScrollPane to the JTable.
I give the JTable a 100 rows with some values. For some reason I can 't scroll.
Is it possible to make it work in this example because I really want to keep the line "contentPane.setLayout(null);" and not use another layout.
Thanks for reading and maybe solving my problem
Code:import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Interface extends JFrame { public Interface() { Container contentPane = getContentPane(); contentPane.setLayout(null); JTable t1 = new JTable(100, 5); JScrollPane s1 = new JScrollPane(t1); contentPane.add(t1); contentPane.add(s1); // Object.setBounds(left, top, with, height); t1.setBounds(1, 100, 500, 500); s1.setBounds(501, 100, 20, 500); for(int i = 0; i < 100; i++) { t1.setValueAt("Value" + i,i,0); } Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); int w = d.width; int h = d.height; this.setSize((int) (((double) w) * 0.9),(int) (((double) h) * 0.9)); this.setLocation((int) (((double) w) * 0.05),(int) (((double) h) * 0.05)); this.setBackground(Color.lightGray ); this.setResizable(false); this.setVisible(true); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } public static void main(String args[]) { Interface window = new Interface(); } }




Reply With Quote