title: How to draw a automata state, circle containing a letter in it using java swing
body: <p>I am trying to draw a circle with a letter in the center of it, which can be entered by the user. Below is the drawing function, but it's not working. (I have to draw a automata state )</p>
  
  <pre><code>private void doDrawingNew(Graphics g) {
      Graphics2D g2d = (Graphics2D) g;
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  
      String nam;
      float cx,cy;
      final Font f = new Font("SansSerif", Font.BOLD, 18);
      JFrame frame = new JFrame("InputDialog Example #1");
      for (int i = 0; i &lt; mylist.size(); i++) {
          GCircle obj = mylist.get(i);
          nam = obj.getName();
  
          if (nam == null) {
              nam = JOptionPane.showInputDialog(frame, "What's your name?");
              obj.setName(nam);
          }
          cx=(float)obj.getX();
          cy=(float)obj.getY();
          cx=+40;
          cy=+40;
          g2d.setColor(new Color(0, 200, 0));
          g2d.fill(obj);
          g2d.setColor(Color.red);
          g2d.setFont(f);
          g2d.drawString(nam, cx, cy);
      }
  }
  </code></pre>