
-----------------------------------
Benner
Fri Apr 19, 2013 10:16 pm

JFrame.setVisible(true) is causing an error?
-----------------------------------
Hi, I finally pinpointed where my error was coming from in my code. I'm not sure if this error is causing any problems in my program as it's not complete yet but It would be nice to figure out why this is happening. 

the code I have is:
[code]
pickP.setLayout(new GridLayout(height, width));
pickF.setContentPane(pickP);

pickF.pack();
pickF.setVisible(true);             //when i remove this line, the error goes away.
pickF.setResizable(false);
pickF.setLocationRelativeTo(null);
[/code]
The error I get is:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeLo(TimSort.java:747)
	at java.util.TimSort.mergeAt(TimSort.java:483)
	at java.util.TimSort.mergeCollapse(TimSort.java:410)
	at java.util.TimSort.sort(TimSort.java:214)
...this goes on for a hundred or so lines.

No where in the (stack?) is there anything to do with code in my project. TimSort is part of the java.util package.

Any help into why this happens would greatly be appreciated. Thanks

Full Code: (line that gives the error is at the bottom)
[code]
package chap9ex14new;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class Chap9ex14new implements ActionListener{
    JFrame pickF, runF, menuF;
    JPanel pickP, runP, menuP;
    JButton start, stop;
    JCheckBox[][] init;
    JLabel[][] cell;
    boolean[][] cellB;
    
    ImageIcon ON;
    ImageIcon OFF;
    
    String path;
    int height, width;
    
    public Chap9ex14new(){
        path = Chap9ex14new.class.getProtectionDomain().getCodeSource().getLocation().getPath();
        OFF = new ImageIcon(path+"/OFF.jpg");
        ON = new ImageIcon(path+"/ON.png");
    
        height = 70;
        width = 115; 
        
        pickF = new JFrame("The Game of Life");
                pickF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        runF = new JFrame("The Game of Life");
                runF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        pickP = new JPanel();
        pickP.setSize(width, height);
        runP = new JPanel();
        runP.setSize(width, height);
        
         start = new JButton("Start");
         start.setActionCommand("start");
         start.addActionListener(this);
         
         stop = new JButton("Stop");
         stop.setActionCommand("stop");
         stop.addActionListener(this);
         
         cell = new JLabel[height][width];      //Label Cells
            for (int i = 0; i 