/**
     * Tries to obtain the image. If an IOException is thrown, we'll assume that no image exists. If
     * everything goes fine, we make the label of that player look like a link and register the
     * ChessclubBoardPanel as a mouse listener.
     */
    public void run() {
      try {
        String playerName = player.isWhite() ? getGame().getWhiteName() : getGame().getBlackName();
        URL url = new URL("http://www.chessclub.com/mugshots/" + playerName + ".jpg");
        InputStream in = url.openStream();
        in.close();

        // openStream() didn't throw an exception, so we'll assume it's ok.
        JLabel label = player.isWhite() ? whiteLabel : blackLabel;
        label.setForeground(Color.blue);
        label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        label.addMouseListener(ChessclubBoardPanel.this);
      } catch (IOException e) {
      }
    }
Exemplo n.º 2
0
  /**
   * Saves the options of the specified seek to be used for the next time when this action is run.
   */
  private void saveSeekOptions(UserSeek seek) {
    Preferences prefs = getPrefs();

    prefs.setInt("time", seek.getTime());
    prefs.setInt("inc", seek.getInc());
    prefs.setBool("isRated", seek.isRated());
    prefs.setString("variant", seek.getVariant().getName());
    Player color = seek.getColor();
    prefs.setString("color", color == null ? "auto" : color.isWhite() ? "white" : "black");
    int minRating = seek.getMinRating();
    int maxRating = seek.getMaxRating();
    prefs.setBool(
        "limitRating", (minRating != Integer.MIN_VALUE) || (maxRating != Integer.MAX_VALUE));
    prefs.setInt("minRating", minRating == Integer.MIN_VALUE ? 0 : minRating);
    prefs.setInt("maxRating", maxRating == Integer.MAX_VALUE ? 9999 : maxRating);
    prefs.setBool("manualAccept", seek.isManualAccept());
    prefs.setBool("useFormula", seek.isFormula());
  }