title: Graphics.drawString() Isn't Drawing
body: <p>I am creating a simple Mahjong game for a final project at school and seem to be having some troubles with the <code>drawString()</code> method on the Graphics/Graphics2D object. I call the <code>drawString</code> method and see nothing written to the screen.</p>
  
  <p>In my scenario I have extended the <code>JFrame</code> class and overridden the <code>paintComponent()</code> method to create a custom graphical object, specifically a mahjong tile. Using polygons described in various arrays I create a faux 3D view of a tile drawing the face, right side, and bottom of the tile. These polygons are filled using <code>GradientPaint</code> objects to give the tile a better appearance. Here is what it looks like:</p>
  
  <p><img src="https://i.stack.imgur.com/Tuk8B.png" alt="Rendered Tile"></p>
  
  <p>My <code>Tile</code> class looks like this (note: some code was omitted for brevity):</p>
  
  <pre><code>public class Tile extends JPanel
  {
      private int _width;
      private int _height;
      private int _depth;
  
      /**
       * Accessor to get the center of the face of the rendered
       * mahjong tile.
       *
       * @return A point containing the center of the face of the tile.
       */
      public Point getCenter()
      {
          return new Point(_width / 2, _height / 2);
      }
  
      /**
       * The default constructor creates a tile that is proportionally
       * calculated to 80 pixels wide.
       */
      public Tile()
      {
          this(80);
      }
  
      /**
       * Given the width parameter a mahjong tile is drawn according to
       * the proportions of a size 8 mahjong tile.
       *
       * @param width The width of the tile to be rendered.
       */
      public Tile(int width)
      {
          _width = width;
          _height = (int)(width * 1.23);
          _depth = (int)((width * 0.3) / 2);
  
          setPreferredSize(new Dimension((_width + _depth) + 1, (_height + _depth) + 1));
      }
  
      @Override public void paintComponent(Graphics g)
      {
          // ... setup polygon arrays ...
  
          super.paintComponent(g);
          Graphics2D g2d = (Graphics2D)g;
  
          // Turn on anti-aliasing.
          g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  
          // ... setup various gradients ...
  
          // Fill the face of the tile.
          g2d.setPaint(faceGradient);
          g2d.fillPolygon(faceXPolyPoints, faceYPolyPoints, faceXPolyPoints.length);
  
          // Fill the right side of the top portion of the tile.
          g2d.setPaint(ivoryRightSideGradient);
          g2d.fillPolygon(ivoryRightSideXPolyPoints, ivoryRightSideYPolyPoints, ivoryRightSideXPolyPoints.length);
  
          // Fill the bottom side of the top portion of the tile.
          g2d.setPaint(ivoryBottomGradient);
          g2d.fillPolygon(ivoryBottomXPolyPoints, ivoryBottomYPolyPoints, ivoryBottomXPolyPoints.length);
  
          // Fill the right side of the bottom portion of the tile.
          g2d.setPaint(jadeRightSideGradient);
          g2d.fillPolygon(jadeRightSideXPolyPoints, jadeRightSideYPolyPoints, jadeRightSideXPolyPoints.length);
  
          // Fill the bottom side of the bottom portion of the tile.
          g2d.setPaint(jadeBottomGradient);
          g2d.fillPolygon(jadeBottomXPolyPoints, jadeBottomYPolyPoints, jadeBottomXPolyPoints.length);
  
          // Draw the outlines for the tile.
          g2d.setPaint(Color.BLACK);
          g2d.drawPolygon(faceXPolyPoints, faceYPolyPoints, faceXPolyPoints.length);
          g2d.drawPolygon(ivoryRightSideXPolyPoints, ivoryRightSideYPolyPoints, ivoryRightSideXPolyPoints.length);
          g2d.drawPolygon(ivoryBottomXPolyPoints, ivoryBottomYPolyPoints, ivoryBottomXPolyPoints.length);
          g2d.drawPolygon(jadeBottomXPolyPoints, jadeBottomYPolyPoints, jadeBottomXPolyPoints.length);
          g2d.drawPolygon(jadeRightSideXPolyPoints, jadeRightSideYPolyPoints, jadeRightSideXPolyPoints.length);
      }
  }
  </code></pre>
  
  <p>As you may know, there are many different types of mahjong tiles one being a character tile that displays various Chinese characters on the tile face. So my <code>Tile</code> class sets up the basic drawing of a tile and I create a new <code>CharacterTile</code> class that extends/inherits the <code>Tile</code> class. The code for that class follows:</p>
  
  <pre><code>public class CharacterTile extends Tile
  {
      private Character _character;
  
      public CharacterTile(Character character)
      {
          super();
  
          _character = character;
      }
  
      @Override public void paintComponent(Graphics g)
      {
          super.paintComponent(g);
          Graphics2D g2d = (Graphics2D)g;
          String charToWrite;
  
  
          switch (_character)
          {
              case ONE:
                  charToWrite = "\u4E00";
                  break;
              case TWO:
                  charToWrite = "\u4E8C";
                  break;
              case THREE:
                  charToWrite = "\u4E09";
                  break;
              case FOUR:
                  charToWrite = "\u56DB";
                  break;
              case FIVE:
                  charToWrite = "\u4E94";
                  break;
              case SIX:
                  charToWrite = "\u516D";
                  break;
              case SEVEN:
                  charToWrite = "\u4E03";
                  break;
              case EIGHT:
                  charToWrite = "\u516B";
                  break;
              case NINE:
                  charToWrite = "\u4E5D";
                  break;
              case NORTH:
                  charToWrite = "\u5317";
                  break;
              case EAST:
                  charToWrite = "\u6771";
                  break;
              case WEST:
                  charToWrite = "\u897F";
                  break;
              case SOUTH:
                  charToWrite = "\u5357";
                  break;
              case RED:
                  charToWrite = "\u4E2D";
                  break;
              case GREEN:
                  charToWrite = "\u767C";
                  break;
              case WAN:
                  charToWrite = "\u842C";
                  break;
              default:
                  charToWrite = "?";
                  break;
          }
  
          g2d.drawString(charToWrite, 0, 0);
      }
  }
  </code></pre>
  
  <p>As you can see the default constructor for the <code>CharacterTile</code> class accepts an <code>enum</code> indicating the desired face value. Inside the overridden <code>paintComponent</code> I have a switch statement that sets the appropriate character to write and then I call the <code>g2d.drawString()</code> method to write the character in the upper left corner. The problem? It doesn't write anything. What am I doing wrong?</p>