Passing an anonymous function to SwingUtilities.invokeLater (in Scala)

As a quick note, if you ever need to call the invokeLater of the Java SwingUtilities class in Scala, you can pass it an anonymous function (lambda) like this:

SwingUtilities.invokeLater(() => {
    // your gui-updating code here, such as:
    for (c <- newsControllers) c.updateContent()

(I haven’t worked with Java 8 lambdas too much, but I assume that the Java lambda syntax is similar to that.)

Java JFrame example: How to display a JFrame

This morning when I saw some Java JFrame code on a mailing list, it made me think that I needed to put a simple JFrame example out here, something that would show how to properly construct and display a JFrame without getting into a discussion of anything else. Here are two examples that show the correct technique.

JDialog focus: How to get input focus on a JDialog

I just solved a problem I was having in a Java Swing application getting input focus on a JDialog in a homemade text editor I use on my Mac OS X systems. Using my initial Java code the JDialog was properly getting input focus the first time it was displayed, but it was not properly getting input focus when it was displayed a second (or any subsequent) time.