Tables [message #114349] |
Fri, 30 December 2005 11:53  |
Eclipse User |
|
|
|
When I put a JTable on a JPane, the table appears in the VE design
screen if I do not set a TableModel. However, it seems that the table
disappears from design view as soon as I set any TableModel. Either way
the Table appears as expected when I run the code. Can the VE display
a Table with a TableModel?
This displays in the VE:
private JTable getMyTable() {
myTable = new JTable();
myTableModel = null;
myTable.setModel(myTableModel);
return myTable;
}
This does not display in the VE:
private JTable getMyTable() {
myTable = new JTable();
myTableModel = new DefaultTableModel();
myTable.setModel(myTableModel);
return myTable;
}
--
Robert Emmons, Aurigen Inc.
remmons@aurigen.com, http://www.aurigen.com
|
|
|
Re: Tables [message #114362 is a reply to message #114349] |
Fri, 30 December 2005 13:48  |
Eclipse User |
|
|
|
Robert,
Yes, in most cases, the Visual Editor can display table models. In fact,
with your code below, it's actually displaying the model you set - since
the model does not have any elements the table is displayed as blank.
When no table model is specified (or it's null) the VE displays the
table with a mock table model (0x0, 0x1, etc).
If you're having problems displaying your custom table model, make sure
that the methods to retrieve values from the model work in design time
(may need some external initialization, connection to a database, etc).
Alternatively, you can return your own mock data from your data model
when being used in design time using the following pattern:
public Object getValueAt(int rowIndex, int columnIndex) {
if (java.beans.Beans.isDesignTime()) {
return "value " + rowIndex + "," + columnIndex;
} else {
return getRealData(rowIndex, columnIndex);
}
}
Hope this helps,
- Jeff
|
|
|
Re: Tables [message #611712 is a reply to message #114349] |
Fri, 30 December 2005 13:48  |
Eclipse User |
|
|
|
Robert,
Yes, in most cases, the Visual Editor can display table models. In fact,
with your code below, it's actually displaying the model you set - since
the model does not have any elements the table is displayed as blank.
When no table model is specified (or it's null) the VE displays the
table with a mock table model (0x0, 0x1, etc).
If you're having problems displaying your custom table model, make sure
that the methods to retrieve values from the model work in design time
(may need some external initialization, connection to a database, etc).
Alternatively, you can return your own mock data from your data model
when being used in design time using the following pattern:
public Object getValueAt(int rowIndex, int columnIndex) {
if (java.beans.Beans.isDesignTime()) {
return "value " + rowIndex + "," + columnIndex;
} else {
return getRealData(rowIndex, columnIndex);
}
}
Hope this helps,
- Jeff
|
|
|
Powered by
FUDForum. Page generated in 0.03217 seconds