I have a GUI grid of squares that I prompt the user for the size of (2^n). Then I ask for the coordinates to put a white square or 'hole' in the grid. I am having trouble putting the user inputted 'hole' into my grid and coloring it white.

My program prompts the user for a power of 2 grid, and displays it. But I've been trying for a couple hours to try and put the 'hole' into my grid and can't seem to get it.

How how do I take these coordinates and place the specified coordinates as a white square?

Here is my code:

Code Java:

import java.util.*; import java.awt.*; import javax.swing.*; class trominoWarZ{ private int currentNum; private int[][] grid; public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("What size board do you want?"); double pw = input.nextDouble(); System.out.println("Coordinates of missing square?"); int x = input.nextInt(); int y = input.nextInt(); myHole hole = new myHole(x,y); //WANT TO SET x,y coord to WHITE super.drawHole(g,x,y); myPan panel = new myPan(pw); //this is how it reads size of board JFrame application = new JFrame(); application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); application.add(panel); application.setSize(400, 400); application.setVisible(true); } } class myPan extends JPanel{ public double pow; public double hc; public static void drawHole(Graphics g, int x, int y) { g.setColor(Color.WHITE); g.fillRect(g,x,y); } public myPan(double p){ pow = p; } public myHole(int h){ hc = h; //I will have the var hc to use for the hole drawHole(hc); } public void paintComponent(Graphics g){ super.paintComponent(g); double num = Math.pow(2,pow); double across; double up; if(hc % 2 == 0){ //is a square across = Math.hc(num,0.5); up = across; } else{ double x = Math.floor(hc/2); double y = x + 1; across = Math.hc(2,x); up = Math.hc(2,y); } if(pow % 2 == 0){ //is a square across = Math.pow(num,0.5); up = across; } else{ double x = Math.floor(pow/2); double y = x + 1; across = Math.pow(2,x); up = Math.pow(2,y); } double wid = 400/across; //width of one double hi = 400/up; //height of one double nowX = 0; double nowY = 0; for(int i = 0; i < up; i++){ //top to bottom nowX = 0; for(int j = 0; j < across; j++){ //System.out.print("*"); g.setColor(Color.BLACK); g.drawRect((int)nowX, (int)nowY, (int)wid, (int)hi); nowX = nowX + wid; } nowY = nowY + hi; //System.out.print("\n"); } //grid or whatever = g.fill } } // public static void tromino(int size, int x, int y) { // int actualsize = 1; // while (actualsize < size) actualsize*=2; // }