title: How to implement dynamic GUI in swing
body: <p>First of all, apologies for posting something perhaps a bit excessively specific, but I'm not very experienced with Swing, and can't seem to find good examples that fit my needs.</p>
  
  <p>So I'm trying to figure out the best way to implement the a dynamic GUI for choosing filtering criteria in Swing:</p>
  
  <p><img src="https://i.stack.imgur.com/m2HLn.png" alt="Mockup of GUI to implement"></p>
  
  <p>The underlying model is a class containing a list of criteria that can be negated (i.e. applied with a NOT-prefix), and a property indicating whether these should be combined with AND or OR.</p>
  
  <p>The GUI would allow the user to add, change or remove criteria, and select the combination operator (and/or). The first criterium would naturally not have a combination-selector, and the third and subsequent criteria would simply use the same combination-operator as the second one.</p>
  
  <p>The X-buttons on the right would be used to delete a criterium. When the Add-button is pressed, a new line of components would be added to the bottom.
  As changes are made, these would be reflected in the underlying model.</p>
  
  <p>Of course I could implement this quite "primitively" by simply adding components to a JPanel and then updating the model accordingly, but I would prefer a neater solution, such as that provided by a TableModel.</p>
  
  <p>So I'm wondering if a table with a custom TableModel and TableCellRenderer/Editor would be the best approach, or if there is a better way to implement something like this. If table is indeed the best approach, I would appreciate some pointers to how one would use TableCellRenderers or -Editors to accomplish this.</p>
  
  <p>Thanks in advance.</p>