Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Starting off by encapsulating things a bit more will make your life much easier. Make a subclass of <code>JPanel</code> that represents the view for one enquiry entry: <code>EnquiryPanel</code>. The <code>EnquiryPanel</code> would have code in it that nearly matches what you pasted above, except that it will fill itself in from the constructor parameters that you pass in and it will be a <code>JPanel</code> itself.</p> <pre><code>public class EnquiryPanel extends JPanel { public EnquiryPanel(Result dbResult) { // your layout code from above, but this is the content pane and // the fields are populated from the dbResult object } } </code></pre> <p>You can then dynamically add instances of <code>EnquiryPanel</code> to a container panel whose layout is a vertical BoxLayout. I call this container panel <code>ResultsPanel</code> below.</p> <pre><code>public class ResultsPanel extends JPanel { public ResultsPanel() { // Layout our contents vertically BoxLayout layout = new BoxLayout(this, BoxLayout.Y_AXIS); this.setLayout(layout); } // method to iterate over the results from the database // construct an EnquiryPanel and add that EnquiryPanel to ourselves public void layoutEnquiryResults(ResultCollection results) { for (Result result : results) { EnquiryPanel eqPanel = new EnquiryPanel(result); add(eqPanel); } revalidate(); } } </code></pre> <p>Finally you would add an instance of <code>ResultsPanel</code> to your <code>JFrame</code>.</p> <pre><code>ResultsPanel resultsPanel = new ResultsPanel(); resultsPanel.layoutEnquiryResults(myResultSet); getContentPane().add(resultsPanel); </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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