View Single Post
  #7 (permalink)  
Old 03-27-2008, 05:49 PM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Code:
import java.awt.*; import javax.swing.*; import javax.swing.table.*; public class TryIt { public static void main(String[] args) { JOptionPane.showMessageDialog(null, new JScrollPane(new MyPanel()), "", JOptionPane.PLAIN_MESSAGE); } } class MyPanel extends JPanel { public MyPanel() { super(new GridLayout(1,0,5,5)); for(int i = 0; i < 3; i++) { JTable table = new JTable(new MyTableModel()); Dimension d = table.getPreferredSize(); d.height = 175; table.setPreferredScrollableViewportSize(d); add(new JScrollPane(table)); } } } class MyTableModel extends AbstractTableModel { public int getRowCount() { return 10; } public int getColumnCount() { return 4; } public Object getValueAt(int row, int col) { return String.valueOf((row+1)) + (col+1); } }
Reply With Quote