title: Java Swing -- Writing a Ui that will repaint itself based on changes to a custom data object
body: <p>First things first -- I had posted a question <a href="https://stackoverflow.com/questions/9761005/java-swing-jpanel-not-rerendering-repainting-itself">earlier</a> wherein i had asked for help as to why my code was not working and this question is acting upon the advice i got in that question.<br></p>
  
  <p>My use case is this.<br></p>
  
  <p>Im writing a <code>MethodEditor</code> module wherein every <code>Method</code> is denoted by a custom data object that has 2 data members --</p>
  
  <ol>
  <li>List of input variable names</li>
  <li>String(name of the result variable that this method sets).</li>
  </ol>
  
  <p>These <code>Method</code> objects are generated as a result of filling out some data on a <code>JDialog</code>.<br>
  These <code>Method</code> objects are stored in a container that has 1 data member that is a <code>List&lt;Method&gt;</code>
  The container resides in a controller <code>JPanel</code> from where the aforementioned <code>JDialog</code> is invoked. <br></p>
  
  <p>From a UI perspective I want to display every <code>Method</code> object in the form of a Jbutton on click of which a <code>JDialog</code> will open and allow the user to edit it.
  <br><br></p>
  
  <p>The <code>MethodEditor</code> acts on a List and generated a vertical arrangement of JButtons, 1 for each <code>Method</code> in <code>List&lt;Method&gt;</code>. This <code>List&lt;Method&gt;</code> is passed to the <code>MethodEditor</code> from the aforementioned controller <code>JPane</code>.</p>
  
  <p>I had in my earlier <a href="https://stackoverflow.com/questions/9761005/java-swing-jpanel-not-rerendering-repainting-itself">question</a> implemented the <code>MethodEditor</code> as a <code>JPanel</code> that would add a <code>PropertyChangeListener</code> to the <code>List&lt;Method&gt;</code> and would <code>repaint</code> itself everytime there was a <code>PropertyChange</code> event but my approach did not work, the repaint would not happen.</p>
  
  <p>Is there another way to get my use case implemented or is there any fix that i could do to my code posted in the earlier <a href="https://stackoverflow.com/questions/9761005/java-swing-jpanel-not-rerendering-repainting-itself">question</a>  ?</p>