Package games.stendhal.client.gui

Examples of games.stendhal.client.gui.ProgressBar


          "Account not created (running standalone)!");
      return;
    }
    // port couldn't be accessed from inner class
    final int finalPort;
    final ProgressBar progressBar = new ProgressBar(owner);

    try {
      port = Integer.parseInt(serverPortField.getText());
    } catch (final Exception ex) {
      JOptionPane.showMessageDialog(owner,
          "That is not a valid port number. Please try again.",
          "Invalid Port", JOptionPane.WARNING_MESSAGE);
      return;
    }
    finalPort = port;

    /* separate thread for connection process added by TheGeneral */
    // run the connection process in separate thread
    final Thread m_connectionThread = new Thread() {

      @Override
      public void run() {
        // initialize progress bar
        progressBar.start();
        // disable this screen when attempting to connect
        setEnabled(false);
 

        try {
          client.connect(server, finalPort);
          // for each major connection milestone call step()
          progressBar.step();
        } catch (final Exception ex) {
          // if something goes horribly just cancel the progress bar
          progressBar.cancel();
          setEnabled(true);
          JOptionPane.showMessageDialog(
              owner,
              "Unable to connect to server to create your account. The server may be down or, if you are using a custom server, " +
              "you may have entered its name and port number incorrectly.");

          logger.error(ex, ex);

          return;
        }

        try {
          final AccountResult result = client.createAccount(
              accountUsername, password, email);
          if (result.failed()) {
            /*
             * If the account can't be created, show an error
             * message and don't continue.
             */
            progressBar.cancel();
            setEnabled(true);
            JOptionPane.showMessageDialog(owner,
                result.getResult().getText(),
                "Create account failed",
                JOptionPane.ERROR_MESSAGE);
          } else {

            /*
             * Print username returned by server, as server can
             * modify it at will to match account names rules.
             */

            progressBar.step();
            progressBar.finish();

            client.setAccountUsername(accountUsername);
            client.setCharacter(accountUsername);

            /*
             * Once the account is created, login into server.
             */
            client.login(accountUsername, password);
            progressBar.step();
            progressBar.finish();

            setEnabled(false);
            if (owner != null) {
              owner.setVisible(false);
              owner.dispose();
            }

            stendhal.setDoLogin();
          }
        } catch (final TimeoutException e) {
          progressBar.cancel();
          setEnabled(true);
          JOptionPane.showMessageDialog(
              owner,
              "Unable to connect to server to create your account. The server may be down or, if you are using a custom server, you may have entered its name and port number incorrectly.",
              "Error Creating Account", JOptionPane.ERROR_MESSAGE);
        } catch (final InvalidVersionException e) {
          progressBar.cancel();
          setEnabled(true);
          JOptionPane.showMessageDialog(
              owner,
              "You are running an incompatible version of Stendhal. Please update",
              "Invalid version", JOptionPane.ERROR_MESSAGE);
        } catch (final BannedAddressException e) {
          progressBar.cancel();
          setEnabled(true);
          JOptionPane.showMessageDialog(
              owner,
              "Your IP is banned. If you think this is not right, please send a Support Request to http://sourceforge.net/tracker/?func=add&group_id=1111&atid=201111",
              "IP Banned", JOptionPane.ERROR_MESSAGE);
        } catch (final LoginFailedException e) {
          progressBar.cancel();
          setEnabled(true);
          JOptionPane.showMessageDialog(owner, e.getMessage(),
              "Login failed", JOptionPane.INFORMATION_MESSAGE);
        }
      }
View Full Code Here


   */
  public void connect(final Profile profile) {
    // We are not in EDT
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        progressBar = new ProgressBar(LoginDialog.this);
        progressBar.start();
        // disable this screen when attempting to connect
        setEnabled(false);
      }
    });
View Full Code Here

TOP

Related Classes of games.stendhal.client.gui.ProgressBar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.