http://www2.gol.com/users/tame/swing/examples/SwingExamples.html
hehe,我把别人给的链接帖给你

解决方案 »

  1.   

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class Test extends JApplet
    {
    JScrollPane jScrollPane1 = new JScrollPane();
    JTable jTable1 = new JTable(10,20); public Test()
    {
    try
    {
    jbInit();
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    }
    private void jbInit() throws Exception
    {
    this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
    jScrollPane1.getViewport().add(jTable1, null);
    }
    public void init()
    {
    TableColumn tc;
    for(int i=0;i<20;i++)
    {
    tc = jTable1.getColumnModel().getColumn(i);
    tc.setMinWidth(i+20);
    tc.setMaxWidth(i+20);
    }
    jTable1.sizeColumnsToFit(0);
    jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    }
    }