Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You almost always want to write your own subclass of AbstractTableModel. At a minimum, you will need to write <code>getRowCount</code>, <code>getColumnCount</code>, and <code>getValueAt</code> methods for it. Typically, a table model returns data based on a private List (such as <code>private List&lt;BoardMessage&gt; messages</code>).</p> <p>The advantage of writing your own model is that the types of each column are a lot easier to keep track of, and there is far less room for error. You can give your model class additional methods like <code>public void addMessage(BoardMessage message)</code> and the model can take care of returning the appropriate values in its getValueAt method. This is much cleaner and less prone to error than just trying to add things to a bare Vector of Vectors.</p> <p>Your model class also acts as, well, a data model, in that you can add a method like <code>public BoardMessage getMessageAt(int row)</code>, which is useful when a user performs an action on a particular message.</p> <p>It's not a good practice to perform JDBC calls inside a table model, because they take time to execute and that will hold up the AWT event dispatch thread, which causes the user interface to become unresponsive. The better thing to do is to execute a JDBC select call in a different Thread, create data objects (such as a List of BoardMessage instances) from the ResultSet, then use <code>EventQueue.invokeLater</code> to update your model with the new data objects.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload