Tuesday 15 May 2012

java - Custom Table Model not working -


I wrote a custom table model. Pairing values ​​in its target list. This list is used throughout the application, if any changes are made in the table, then there is a change in the application that turns out to be my problem, my table JTable rows Does not display.

This is my first custom table model, so I'm not sure I'm missing something.

The table has been created with this code:

  Public CBT (list & lt; T & gt; element; Class; class & gt; classType) { Super bindingModel (elements); This.tableModel = (BindingTableModel & lt; T & gt;) getModel (); This.classType = classType; SetBindings (); Repaint (); }  

An example of set-binding is:

  @ Override protected zero set bonding () {addBinding (ProfessionalDelegate.DELEGAGE_PROPERTY_TYPE, "Type", String Class, false); AddBinding (ProfessionalDelegate.ENTITY_PROPERTY_NAME, "name", string, class, true); ...  

And the actual model is this:

  public class BindingTableModel & lt; T & gt; AbstractTableModel implements TableModel {Private list & lt; T & gt; Elements; Private listing & lt; BindingTableModelInfo & gt; BindingInfo; Private map & lt; Point, object & gt; ValueMap; Public BindingTable Model (List & lt; T & gt; Element) {these.elements = elements; This.bindingInfo = New ArrayList & lt; & Gt; (); ValueMap = new hashmap & lt; & Gt; (); Tie (); For (Int i = 0; I & lt; getRowCount (); i ++) {FireTableROINSTED (I, I); } FireTableStructureChanged (); } Public Zero addBindingInfo (string property name, string column name, class cl ic, boolean image) {bindingInfo.add (new binding modellinfo (property name, column name, call class, enabled)); } Private zeroless bind (for (int col = 0; col & lt; getColumnCount (); col ++) {for (int row = 0; line & lt; getRowCount (); line ++) {getValueAt (Line, color); // This map will be init}}} Public Zero addElement (T element) {elements.add (element);} Public list & lt; T & gt; GetElements () {return element;} Public zero Delete Element {int index = elements.indexOf (element); elements.remove (element); FireTableRows deleted (index, index);} @ override public intervount () {return elements (.;)}} @ override Public int column Columns () {Return Binding Infosys ();} @ Override Public String getColumnName (int i) {bindingInfo.get (i) .getColumnName ();} @ Override Public Class  

fireTableCellUpdated () or any other appropriate event ; This is usually done in the implementation of setValueAt () :

  @Override public zero set value (object value, int row, int col) {... FireTableCellUpdated (line, col); }  

The complete example is seen and seen.


No comments:

Post a Comment