1 Reply Latest reply on Apr 19, 2007 10:32 AM by 807599

    Columns in JTable, Help!

    807599
      Hello There,

      I have two question about the JTable in Java:

      1. How can i set a column width? I want to have one column widder than the other and not editable at runtime.

      2. How can i have multiple lines (block of data/small paragraph) in one cell? because whenver i write a 3 new lines of data in a cell the JTable converts it cont. line.

      Please Help!!
        • 1. Re: Columns in JTable, Help!
          807599
          Here there is a JTable where 3 colums are being resized
          TableColumn column1 = null;
                         for (int i = 0; i < 3; i++) {
                             column1 = table1.getColumnModel().getColumn(i);
                             if (i == 0) {
                                 column1.setPreferredWidth(20);
                             } else {
                                  if (i == 1){
                                       column1.setPreferredWidth(160);
                                  }
                                  else
                                  {
                                       column1.setPreferredWidth(80);
                                  }
                             }
                         }