private void initComponents(String title) {
    getContentPane().setLayout(new BorderLayout());

    JPanel mainPane = new JPanel(new BorderLayout());
    mainPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JLabel text = new JLabel(title, JLabel.CENTER);
    text.setFont(FONT);
    text.setOpaque(true);
    text.setBackground(Color.orange);
    //		text.setFont(UIManager.getFont("Label.font"));
    mainPane.add(text, "North");

    JPanel panel = new JPanel(new GridLayout(1, 6));
    for (int i = 1; i <= 6; i++) {
      Die die = template.getCopy();
      die.setFace(i);
      FaceButton button = new FaceButton(die, i);
      panel.add(button);
    }
    mainPane.add(panel, "South");

    if (icon != null) {
      JLabel iconLabel = new JLabel(icon);
      iconLabel.setBorder(BorderFactory.createEtchedBorder());
      mainPane.add(iconLabel, "Center");
    }

    getContentPane().add(mainPane, "Center");
    setResizable(false);
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    pack();
  }
  // Draws this die when rolling with a random number of dots
  private void drawRolling(Graphics g) {
    int x = xCenter - dieSize / 2 + (int) (3 * Math.random()) - 1;
    int y = yCenter - dieSize / 2 + (int) (3 * Math.random()) - 1;
    g.setColor(Color.RED);

    if (x % 2 != 0) g.fillRoundRect(x, y, dieSize, dieSize, dieSize / 4, dieSize / 4);
    else g.fillOval(x - 2, y - 2, dieSize + 4, dieSize + 4);

    Die die = new Die();
    die.roll();
    drawDots(g, x, y, die.getNumDots());
  }
 // Starts this die rolling
 public void roll() {
   super.roll();
   int width = tableRight - tableLeft;
   int height = tableBottom - tableTop;
   xCenter = tableLeft;
   yCenter = tableTop + height / 2;
   xSpeed = width * (Math.random() + 1) * speedFactor;
   ySpeed = height * (Math.random() - .5) * 2. * speedFactor;
 }