🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17125

Jtable column names..

#17125
From: Claire Kennedy
Date: Fri, 11 Dec 1998 00:00
67 lines
2550 bytes
I'm trying to implement a jtable using a table model.  I have set up the

data and the column names in the table.  The data is displaed in the
Jtable but the the coulmn names don't seem to apear has anyone any ideas

what might cause this.
Thanks
Claire

..
 //Construct jtable using myModel
  MyTableModel myModel = new MyTableModel();
  JTable jTable2 = new JTable(myModel);
 //Create the scroll pane and add the table to it.
  JScrollPane scrollPane1 = new JScrollPane(jTable2);
.
.
class MyTableModel extends AbstractTableModel
 {
        final String[] columnNames = {"Booked", "Type", "Transacted",
"     ", "Settlement",
                                      "Rate", "Maturity", "POS/VAL",
"Reval"};
        final Object[][] data = {
            {"10 NOV", "DS", "9000000", "USD/IEP", "7,000,000",
"1.50000", "   xx", "N/A", "N/A"},
            {"21 NOV", "DS", "2000000", "USD/IEP", "2,800,000",
"1.50000", "11 DEC", "N/A", "N/A"},
            {"25 NOV", "DS", "8900000", "USD/IEP", "9,000,000",
"1.50000", "11 DEC", "N/A", "N/A"},
            {"27 NOV", "DS", "1000000", "USD/IEP", "2,000,000",
"1.50000", "11 DEC", "N/A", "N/A"},
            {"1 DEC", "DS", "5000000", "USD/IEP", "7,000,000",
"1.50000", "11 DEC", "N/A", "N/A"}};

        public int getColumnCount ()
        {
            return columnNames.length;
        }

        public int getRowCount ()
        {
            return data.length;
        }

        public String getColumnName(int col) {
           return columnNames[col];
        }

        public Object getValueAt(int row, int col) {
            return data[row][col];
        }

        public Class getColumnClass(int c) {
            return getValueAt(0, c).getClass();
        }

        public boolean isCellEditable(int row, int col) {
            //Note that the data/cell address is constant,
            //no matter where the cell appears onscreen.
            if (col < 2) {
                return false;
            } else {
                return true;
            }
        }
}
Technical Details
Message-ID: <36712BEC.6A128861@ifs.ie>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,e29a1071149d1761,start
X-Google-Attributes: gidf74b3,public
From: Claire Kennedy <claire.kennedy@ifs.ie>
Subject: Jtable column names..
Date: 1998/12/11
Message-ID: <36712BEC.6A128861@ifs.ie>
X-Deja-AN: 421190098
Content-Transfer-Encoding: 7bit
Organization: Indigo
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language