MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / paintComponent

Method paintComponent

src/demoJS/CursorTest2.java:107–122  ·  view source on GitHub ↗
(Graphics g)

Source from the content-addressed store, hash-verified

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");

Callers

nothing calls this directly

Calls 5

minMethod · 0.80
fillOvalMethod · 0.80
getWidthMethod · 0.65
getHeightMethod · 0.65
setColorMethod · 0.45

Tested by

no test coverage detected