Print

Print


The issue is that ECJ calls Finisher just before it does a 
System.exit(0), which by default destroys all threads and exits 
(including the graphical interface one you just created).  You'll need 
to modify this.  Assuming your'e using Evolve.java, try commenting out 
its last line:
	// System.exit(0);

K S wrote:

> I overrode the ec.simple.SimpleFinisher class as follows:
> 
> package collaboration.gp.finisher;
> 
> import java.awt.BorderLayout;
> import java.awt.event.WindowAdapter;
> import java.lang.reflect.InvocationTargetException;
> 
> import javax.swing.JFrame;
> import javax.swing.JTextArea;
> 
> import GP.ERCIndicatorInterface;
> import ec.EvolutionState;
> import ec.Individual;
> import ec.gp.ADFStack;
> import ec.gp.GPDefaults;
> import ec.gp.GPIndividual;
> import ec.gp.koza.KozaStatistics;
> import ec.simple.SimpleFinisher;
> import ec.util.Parameter;
> import graphics.ChartDisplay;
> 
> public class RunFinisher extends SimpleFinisher {   
>     public void finishPopulation(final EvolutionState state, final int 
> result)
>     {
>        
>         JFrame f = new JFrame("A JFrame");
>         f.setSize(250, 250);
>         f.setLocation(300,200);
>         f.getContentPane().add(BorderLayout.CENTER, new JTextArea(10, 40));
>         f.setVisible(true);   
>     }
> }
> 
> However, the JFrame that pops up only stays for less than a second.  If 
> I create a JFrame as follows:
> ||
> import java.awt.BorderLayout;
> import javax.swing.*;
> 
> public class JFrameTester {
>       public static void main(String[] args) {           
>             JFrame f = new JFrame("A JFrame");
>             f.setSize(250, 250);
>             f.setLocation(300,200);
>             f.getContentPane().add(BorderLayout.CENTER, new 
> JTextArea(10, 40));
>             f.setVisible(true);           
>           }
> } 
> 
> The JFrame is visible / the program does not terminate until I close the 
> JFrame.  How do I make the JFrame in the RunFinisher
> class above stay visible / active until I close it?
> ||
> ------------------------------------------------------------------------
> Bing™ brings you maps, menus, and reviews organized in one place. Try it 
> now. 
> <http://www.bing.com/search?q=restaurants&form=MLOGEN&publ=WLHMTAG&crea=TEXT_MLOGEN_Core_tagline_local_1x1>