change jtable's column hedding according different actionPerforms
I have a Jtable extending AbstractTableModel,And I have differnt buttons in my form ,When click on different buttons differnt types of data is lo开发者_StackOverflow中文版aded in the table,I want to set suitable column hedding on different click of buttons
Since "different types of data" must be loaded to the JTable, you need different AbstractTableModels. myModelA, myModelB, myModelC etc.
You can set the appropriate model with:
myTable.setModel(new myModelA());
and
myTable.setModel(new myModelB());
etc, at the ActionListener - actionPerformed() of your buttons. Each model will provide headings for the appropriate data.
精彩评论