I am trying to code an application that resembles a Karnaugh Map, and I want to draw an ellipse to enclose a group of numbers.
What I have is a JFrame, which has a JPanel with a GridLayout, where I add several other panels to it. So, in the end, I have a grid-like interface. I want the ellipse to be on top of these panels.
I am trying to use Graphics2D and the method draw(), but I cannot even begin to understand how to instantiate the Graphics2D object.
What I've done is: get the Graphics object from the JPanel with the GridLayout, then
g is the Graphics object.
Graphics2D g2 = (Graphics2D) g;
g2.draw(new Ellipse2D.Double(x, y,rectwidth,rectheight));
Then repaint() the gridlayout panel, but nothing happens and it doesnt throw an exception or anything.
What am I doing wrong?