Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #5294

Re: Outside of the EDT: JOptionPane.showMessageDialog

Newsgroups comp.lang.java.gui
Date 2012-12-31 12:00 -0800
References (3 earlier) <nospam-D5E268.10234727122012@news.aioe.org> <EDT-20121227165216@ram.dialup.fu-berlin.de> <nospam-68BF57.16343427122012@news.aioe.org> <EDT-20121227231618@ram.dialup.fu-berlin.de> <nospam-0E3B0C.10384729122012@news.aioe.org>
Message-ID <79179e83-8899-48bf-8c03-334065d380de@googlegroups.com> (permalink)
Subject Re: Outside of the EDT: JOptionPane.showMessageDialog
From Lew <lewbloch@gmail.com>

Show all headers | View raw


John B. Matthews wrote:
> (Stefan Ram) wrote:
>> public class Main
>> { public static void main( final java.lang.String[] args )
>>   { final javax.swing.JFrame frame = new javax.swing.JFrame( "Hallo Swing!" );
>>     frame.setDefaultCloseOperation( javax.swing.JFrame.EXIT_ON_CLOSE );
>>     frame.setVisible( true ); }}
> 
>>   It hurts somewhat to see this, but this example appears

For two reasons.
 
I respect Stefan's knowledge, logic and code, but not his layout.

He's explained his reasons and I accept them. From him.

But don't agree. Like as if it mattered whether I do or not.

Pedagogically his style is useful, as it gives a contrast between 
idiosyncratic and conventional styles, and students / interested parties
may make their own determination as to the relative merits.

>>   just after the introduction of »new«, and makes the effect
>>   of »new« visible somehow, so I thought it might be a good
>>   motivation. In a sense, a JFrame is a »visible object«, so
>>   this example visualizes objects, which might help to learn.
>>   But I have not yet introduced interface implementations, and
>>   so I cannot yet implement java.lang.Runnable.

Pedagogical purposes often include introduction of flawed code for a 
later twist. I heard an economics professor explain once how "guns and 
butter" didn't make actual real-world sense, of course, but was important
to provide common ground and to introduce the terminology and techniques 
of economic analysis. Analysis of the limitations of introductory models
is a standard way to grow a student's skills.

> This seems like a reasonable compromise. When returning to the 
> topic, the example is simple enough to trace execution and show 
> that, while a particular implementation may be thread-safe, 

Or you could go with John's more succinct and accessible way of saying 
what I just rephrased.

> there is no general assurance without starting on the EDT. The 
> didactic problem is complicated by the fact that incorrect 
> examples rarely fail reliably, and examples that fail reliably 
> are often so contrived as to to be obviously incorrect.

Two great points to bring to young minds' attention early on.

It also helps to introduce the notion of exogenous factors. The point 
is that no factor can truly be ruled out as irrelevant. Many threading 
bugs, in particular EDT ones and the change of Swing docs to reflect this,
were not recognized until the generalized shift to multiprocessor mobos 
in the early oughts. This exposed both the blooms and the thorns of the 
foresightful Java concurrency rose garden.

You might think the JVM insulates one from the exigencies of hard hardware.
Turns out you cannot ignore context entirely.

Another good thing to remark during early training.

-- 
Lew

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar


Thread

Re: Outside of the EDT: JOptionPane.showMessageDialog Knute Johnson <nospam@knutejohnson.com> - 2012-12-26 22:03 -0800
  Re: Outside of the EDT: JOptionPane.showMessageDialog "John B. Matthews" <nospam@nospam.invalid> - 2012-12-27 10:23 -0500
    Re: Outside of the EDT: JOptionPane.showMessageDialog Knute Johnson <nospam@knutejohnson.com> - 2012-12-27 09:06 -0800
      Re: Outside of the EDT: JOptionPane.showMessageDialog "John B. Matthews" <nospam@nospam.invalid> - 2012-12-27 16:16 -0500
    Re: Outside of the EDT: JOptionPane.showMessageDialog "John B. Matthews" <nospam@nospam.invalid> - 2012-12-27 16:34 -0500
      Re: Outside of the EDT: JOptionPane.showMessageDialog "John B. Matthews" <nospam@nospam.invalid> - 2012-12-29 10:38 -0500
        Re: Outside of the EDT: JOptionPane.showMessageDialog Lew <lewbloch@gmail.com> - 2012-12-31 12:00 -0800

csiph-web