Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2010
    Posts
    4

    Post Unanswered: how to setsize for columns of JTable

    Please help me

    In my JTable maybe have a lot of columns.

    How can i set size of each column?
    How can i have horizontal scroll bar if have too columns?


    please help

  2. #2
    Join Date
    Feb 2010
    Posts
    4
    JTable table=new JTable();//your table should have JScollPan and already setsize in JFrame
    ......................

    DefaultTableModel model=new DefaultTableModel();
    TableColumn col;

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setModel(model);
    model.addColumn("TNAME");
    model.addColumn("TABTYPE");
    model.addColumn("CLUSTERID");

    col=table.getColumnModel().getColumn(0);
    col.setPreferredWidth(300);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •