JTable header Render (Center Text on Column header)

HI AllCan some one please help me ? I am trying to center the text of Column headers of my table.I am not have very much luck with it can someone show me how ?Thanks for any feed backCraig
[230 byte] By [kiwioza] at [2007-10-2 4:03:47]
# 1
I have Got it working with ((DefaultTableCellRenderer)table.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(SwingConstants.CENTER);ThanksCraig
kiwioza at 2007-7-15 23:26:18 > top of Java-index,Desktop,Core GUI APIs...
# 2
How to change the column headings of JTable during ' I18N ' & if you are using variables for the column names which should be refreshed everytime a language is changed
abhijeeta at 2007-7-15 23:26:18 > top of Java-index,Desktop,Core GUI APIs...
# 3

Generally, it would have been better to start a new thread rather than appending your question to a thread whose only relation to your topic is that it too concerns JTableHeader.

Without a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] that provides a framework for comments, it is hard to give you any specific advice.

That said, presumably you are using the values of the variables at some point to specify the column headers. This might be when you construct the table, or perhaps in the TableModel.

When the language is changed, you then change the values of those variables. Your table model then needs to do exactly what AbstractTableModel#fireTableStructureChanged does.

JayDSa at 2007-7-15 23:26:18 > top of Java-index,Desktop,Core GUI APIs...
# 4
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);This method will automatically keep your column names at center.
sathiqa at 2007-7-15 23:26:18 > top of Java-index,Desktop,Core GUI APIs...