| 105 | |
| 106 | JPanel drawingPanel = new JPanel() { |
| 107 | @Override |
| 108 | protected void paintComponent(Graphics g) { |
| 109 | super.paintComponent(g); |
| 110 | // Get the dimensions of the panel |
| 111 | int width = getWidth(); |
| 112 | int height = getHeight(); |
| 113 | // Calculate the coordinates for the center of the panel |
| 114 | int centerX = width / 2; |
| 115 | int centerY = height / 2; |
| 116 | // Define the radius of the circle |
| 117 | int radius = Math.min(width, height) / 4; |
| 118 | // Set the color to red |
| 119 | // Draw the circle |
| 120 | g.setColor(clickToggle ? Color.BLUE : Color.RED); |
| 121 | g.fillOval(centerX - radius, centerY - radius, 2 * radius, 2 * radius); |
| 122 | } |
| 123 | }; |
| 124 | |
| 125 | drawingPanel.setName("drawingPanel"); |