Java JTable restructure / reload / refresh -


I have a tree and a table, when I click on the tree node, the time the table will change on the same, but It is not. I search online and read Java tutorials and I do not find any solutions. From some posts I think I need to use fireTableStruetureChanged () , but it does not work in my code Can anyone help me with this? The following code is thanks a ton!

  Change the table structure of the public category increases the geometric tool ... {..... // // column name is a public variable, because I'll have to change the column later column name = new string [] {"Col1", "col2"}; * / Data = new string [] [] {{"Mary", "champion"}, {"alison", "attack"},}; Table = new JTable (new MyTableModel ()); Table.setAutoCreateColumnsFromModel (wrong); Feedback = new JScrollPane (table); // is the response panel below  

...

 } // Following is the square problem, I need to reload the table i when class , But the table is not changed in all public Zero Exhibits. Fabke (String Template String) {// Create table for panel column below name = new string [] {"col3", "col4", "col5"}; String [] [] Data = New string [] [] {{"Mary", "Campione", "We"}, {"Alison", "Humble", "Canada"}}}; // table = new JTable (data, column-name); // fireTableStructureChanged (); // This table is the problem I table model class MyTableModel AbstractTableModel {String [columnnames = new string] Extends {"col1", "col2"}  
  public int getColumnCount () { Return columnNames.length; } Public int getRowCount () {return data. Long; } Public string getColumnName (int col) {returning column names [col]; } Public object getValueAt (int row, int col) {return data [row] [cola]; }}  

...}

In your method, Code> Display Feedback You are expecting to change the Joint object and there is a change in display to display the selected code in JTree . Instead of taking a place in the view object, you should focus your efforts on updating the model , in this case, the AbstractTableModel subclass is ready Already happened. There are some methods you can do, but there is proof of concept for a tremendous force, you can do something like:

  • Adds a 2-dimensional array in data
  • , create a new example of MyTableModel , which is the new data related to selected selected tree nodes is.
  • Call setModel on your global table variable

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -