This program draws two circles of the inputted size on a jPanel, one on top of another. The problem is, the two circles are not centered. How can i solve this?
Code:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jPanel.Repaint();
try{
jLabel6.setText("");
int a=Integer.parseInt(jTextField1.getText());
Graphics2D gfx=(Graphics2D)jPanel1.getGraphics();
gfx.clearRect(0, 0, getWidth(), getHeight());
gfx.setColor(Color.red);
gfx.fillOval(100,50,a,a);
gfx.fillOval(100,50,a,a);
}catch(NumberFormatException e){
jLabel6.setText("Incorrect data");
}
}
Result: