>> Message: 1
> From: "jai" <mjn@...>
> To: <jython-users@...>
> Date: Tue, 13 Jan 2004 17:38:14 +0530
> Subject: [Jython-users] How to check the table header name using jython
> how will u check the table header name using jython.
There really isn't much difference between Jython and Java in this regard,
other than the
shorter notation that jython provides. Some good info at Sun's Java
Ok, I'm not sure what you mean by "header name". Do you mean the title of a
JTables are fairly flexible, and hence have some complexity. JTables have
and a DataModel, whether you define them or are using the defaults. From
ColumnModel you can retrieve info about the column titles.
# You've created a table
table = JTable(....)
# Here's the table header. Maybe this is what you wanted?
tableHeader = table.getTableHeader()
# To get the title of a column, there are a few ways.
# Either get the columnModel and retrieve name from their, or retrieve name
straight from table.
# You can get the column model a few different ways
columnModel = tableHeader.getColumnModel()
columnModel = table.getColumnModel()
# Then you can get the column and it's title
tableColumn = columnModel.getColumn(index)
columnTitleString = tableColumn.getIdentifier()
# Alternatively you can retrieve the the column title straight from the
columnTitleString = table.getColumnName(columnNumber)
Bear in mind that the column model and the view may be two different things
depending on how you
implemented your table. For example, if a user moved a column, the column
number for a column in
the view will represent a different column than the same number column in
If this didn't answer your question, experiment, and ask again w/ more