6
6e
I made a class that extends jtable. But its acting a bit weird.
The first thing I do in the constructor is to call the
super(data,columnnames). This would seemingly make a Jtable object
yes?
However each time that I try to say... this.getColumnCount(), the
result is 0. if I try to get a specific column, of course I get a
arrayindexoutofbounds -1 error.
Im confused and lost as to what the problem is...
Ive posted some simplified code below for your perusal...
Thanks!
-----------"main" code--------------------------------
String[] columnNames = {"Format Label", "Role", "Name", "", "", "", "",
""};
Object[][] data = {
{" ", " ", " ", imgSpecial, imgUp, imgDown, imgToTop, imgToBottom},
{" ", " ", " ", imgSpecial, imgUp, imgDown, imgToTop, imgToBottom}
};
myTable = new MyTable(data, columnNames);
----MyTable constructor...------------------------------------
public MyTable(Object[][] data, String[] columnNames){
super(data,columnNames);
//set font size
this.setFont(new Font("Courier", Font.PLAIN, 13));
//no column moving
this.getTableHeader().setReorderingAllowed(false);
System.out.println("Hltable column count =" + this.getColumnCount());
//equals zero!
this.getColumnModel().getColumn(this.convertColumnIndexToView(iRole));
//breaks the code with an arrayindexoutofbounds error..
The first thing I do in the constructor is to call the
super(data,columnnames). This would seemingly make a Jtable object
yes?
However each time that I try to say... this.getColumnCount(), the
result is 0. if I try to get a specific column, of course I get a
arrayindexoutofbounds -1 error.
Im confused and lost as to what the problem is...
Ive posted some simplified code below for your perusal...
Thanks!
-----------"main" code--------------------------------
String[] columnNames = {"Format Label", "Role", "Name", "", "", "", "",
""};
Object[][] data = {
{" ", " ", " ", imgSpecial, imgUp, imgDown, imgToTop, imgToBottom},
{" ", " ", " ", imgSpecial, imgUp, imgDown, imgToTop, imgToBottom}
};
myTable = new MyTable(data, columnNames);
----MyTable constructor...------------------------------------
public MyTable(Object[][] data, String[] columnNames){
super(data,columnNames);
//set font size
this.setFont(new Font("Courier", Font.PLAIN, 13));
//no column moving
this.getTableHeader().setReorderingAllowed(false);
System.out.println("Hltable column count =" + this.getColumnCount());
//equals zero!
this.getColumnModel().getColumn(this.convertColumnIndexToView(iRole));
//breaks the code with an arrayindexoutofbounds error..