Frame only updates once size is changed

Hi all

I run into a bit of a problem with some code today, what it is supposed to do is detect mouse clicks and then update the frame. Now this starts off fine, however when I want it to do two functions upon one mouseclick, it only wants to update the frame if I resize the screen and return. I'm not sure what's causing it, this is my main method.
import javax.swing.JFrame;

public class Main {
	
	//Technical stuff
	static JFrame frame = new JFrame();
	public static boolean waitingInput = true;
	public static int whatInput = 0;
	static Menu menu = new Menu();
	static CountryInput CI = new CountryInput();
	
	//Player info
	public String pName = null;
	public String cName = null;
	
	public static void main(String[] args) throws InterruptedException{
		Functions.nameGenerate();
		frame.setVisible(true);
		frame.setSize(600, 400);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.add(menu);
		menu.setVisible(true);
		
		check();
	}
	
	//Used to handle when something is clicked
	
	public static void check() throws InterruptedException{
		while(waitingInput == true){ //Before/After something is clicked
			Thread.sleep(10);
			frame.repaint();
		}
		if(whatInput == 1){ //When menu is pressed
			frame.remove(menu);
			frame.add(CI);
			whatInput = 2;
		}
		else if(whatInput == 2){
			frame.add(CI);
		}
	}
	
}

All help appreciated

Comments

Sign In or Register to comment.