Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The reason why they arent showing is because you are probably calling the static <code>showCourseListDialog()</code> to show your dialog. This method will test whether your static <code>courseListDialog</code> is null, and if so, create one and set <em>that</em> dialog visible, not the <code>clf</code> that you instantiated. </p> <p>If in your <code>showCourseListDialog()</code> you call the <code>addCourses()</code> method after instantiating your 'singleton', you should be OK:</p> <pre><code>public static void showCourseListDialog() { if (courseListDialog == null) { courseListDialog = new CourseListFrame(); courseListDialog.addCourses();// &lt;&lt;---- this is key! } courseListDialog.pack(); courseListDialog.setVisible(true); courseListDialog.setSize(260, 180); } </code></pre> <p>That said, by having the <code>static</code> <code>courseListDialog</code>, it is apparent that you want that dialog to be a singleton. If that is the case, I would <em>at least</em> make your constructor <code>private</code>. You want to proactively avoid the situation that you are getting into where you can construct multiple instances of a singleton. You still would have a race condition to deal with in your <code>showCourseListDialog</code>, but as you will only be calling this method in the EDT, you should be safe.</p> <p>Take a look at <a href="https://stackoverflow.com/questions/70689/efficient-way-to-implement-singleton-pattern-in-java">this</a> and other topics on Singleton development in Java (and dont forget to read the <a href="https://stackoverflow.com/search?q=singleton+antipattern">con arguments</a> where it is described as an anti-pattern) </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. VO
      singulars
      1. This table or related slice is empty.
    2. 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