Package mdes.slick.sui.event

Examples of mdes.slick.sui.event.ActionListener


          m_login.tabKeyDefault();
      }

      if (key == (Input.KEY_ESCAPE)) {
        if(m_confirm==null){
          ActionListener yes = new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
              try {
                System.exit(0);
              } catch (Exception e) {
                e.printStackTrace();
              }

            }
          };
          ActionListener no = new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
              m_confirm.setVisible(false);
              getDisplay().remove(m_confirm);
              m_confirm = null;
            }
View Full Code Here


   * When the close button is pressed...
   * @param args
   */
  public boolean closeRequested(){
    if (m_confirm == null){
      ActionListener yes = new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
          try {
            System.exit(0);
            m_close = true;
          } catch (Exception e) {
            e.printStackTrace();
            m_close = true;
          }
        }
      };
      ActionListener no = new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
          m_confirm.setVisible(false);
          getDisplay().remove(m_confirm);
          m_confirm = null;
          m_close = false;
View Full Code Here

    setBackground(new Color(0, 0, 0, 85));
    setTitle("Friends");
    setSize(170, 180);
 
    m_up = new SimpleArrowButton(SimpleArrowButton.FACE_UP);
    m_up.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e) {
        scroll(-1);
      }
    });
    m_up.setEnabled(false);
    m_up.setSize(15, 15);
    m_up.setLocation(getWidth() - 15, 0);
    getContentPane().add(m_up);
    m_down = new SimpleArrowButton(SimpleArrowButton.FACE_DOWN);
    if (m_friends.size() <= 10)
      m_down.setEnabled(false);
    m_down.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e) {
        scroll(1);
      }
    });
    m_down.setSize(15, 15);
View Full Code Here

    getTitleBar().setVisible(false);
    setVisible(true);
    setResizable(false);
    setAlwaysOnTop(true);
   
    m_remove.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
        destroy();
        ActionListener m_yes = new ActionListener(){
          public void actionPerformed(ActionEvent e){
            GameClient.getInstance().getPacketGenerator().writeTcpMessage("Fr" + m_name.getText());
            GameClient.getInstance().getDisplay().remove(m_confirm);
            m_confirm = null;
          }
        };
        ActionListener m_no = new ActionListener(){
          public void actionPerformed(ActionEvent evt) {
            GameClient.getInstance().getDisplay().remove(m_confirm);
            m_confirm = null;
          }
        };
        m_confirm = new ConfirmationDialog("Are you sure you want to remove " + m_name.getText() + " from your friends?");
        m_confirm.addYesListener(m_yes);
        m_confirm.addNoListener(m_no);
      }
    });
    m_cancel.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
        destroy();       
      }
    });
  }
View Full Code Here

   
    m_login = new Button(translated.get(7));
    m_login.setSize(64, 32);
    m_login.setLocation(m_password.getX(), m_password.getY() + m_password.getHeight() + 8);
    m_login.setVisible(true);
    m_login.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
        if(m_username.getText() != null & !m_username.getText().equalsIgnoreCase("") &&
            m_password.getText() != null && !m_password.getText().equalsIgnoreCase("")) {
          login();
        }
      }
    });
    this.add(m_login);
   
    m_register = new Button(translated.get(8));
    m_register.setSize(64, 32);
    m_register.setLocation(m_login.getX() + m_login.getWidth() + 8, m_login.getY());
    m_register.setVisible(true);
    m_register.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent arg0) {
        register();
      }
    });
    this.add(m_register);
View Full Code Here

 
  /**
   * Cancels the trade
   */
  private void cancelTrade(){
    ActionListener yes = new ActionListener(){
      public void actionPerformed(ActionEvent evt) {
        GameClient.getInstance().getPacketGenerator().writeTcpMessage("TC");
        m_confirm.setVisible(false);
        getDisplay().remove(m_confirm);
        m_confirm = null;
        setVisible(false);
        GameClient.getInstance().getUi().stopTrade();
        System.out.println("Trade Cancelled");
      }
   
    };
    ActionListener no = new ActionListener(){
      public void actionPerformed(ActionEvent evt) {
        getDisplay().remove(m_confirm);
        m_confirm = null;
      }
    };
View Full Code Here

    m_makeOfferBtn = new Button();
    m_tradeBtn = new Button();
    m_cancelBtn = new Button();
   
    //Action Listener for the offer button
    m_offerListener = new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        if (m_makeOfferBtn.getText().equalsIgnoreCase("Make Offer")){
          if(m_ourMoneyOffer.getText().equals("") || m_ourMoneyOffer.getText() == null){
            m_ourMoneyOffer.setText("0");
          }
          makeOffer();
        }
        else {
          cancelOffer();
        }
      }
    };
   
    int x = 10, y = 10;
    for (int i = 0; i < 6; i++){
      //Show Our Pokemon for Trade
      m_ourPokes[i] = new ToggleButton();
      m_ourPokes[i].setSize(32, 32);
      m_ourPokes[i].setVisible(true);
      try {
        m_ourPokes[i].setImage(GameClient.getInstance().getOurPlayer()
            .getPokemon()[i].getIcon());
      } catch (NullPointerException e){
        m_ourPokes[i].setGlassPane(true);
      }
     
      getContentPane().add(m_ourPokes[i]);
      if (i < 3)
        m_ourPokes[i].setLocation(x, y);
      else
        m_ourPokes[i].setLocation(x + 40, y);
     
      //Show the Other Character's Pokemon for Trade
      m_theirPokes[i] = new ToggleButton();
      m_theirPokes[i].setSize(32, 32);
      m_theirPokes[i].setVisible(true);
      m_theirPokes[i].setGlassPane(true);
      getContentPane().add(m_theirPokes[i]);

      //Item Location Algorithms
      if (i < 3)
        m_theirPokes[i].setLocation(x + 178, y);
      else
        m_theirPokes[i].setLocation(x + 218, y);
   
      if (i == 2)
        y = 10;
      else
        y += 40;
    }
    m_ourPokes[0].addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        if (m_offerNum == 0){
          m_offerNum = 6;
          untoggleOthers(6);
        } else {
          m_offerNum = 0;
          untoggleOthers(0);
        }
        m_makeOfferBtn.setEnabled(true);

      };
    });
    m_ourPokes[1].addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        if (m_offerNum == 1){
          m_offerNum = 6;
          untoggleOthers(6);
        } else {
          m_offerNum = 1;
          untoggleOthers(1);
        }
        m_makeOfferBtn.setEnabled(true);

      };
    });
    m_ourPokes[2].addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        if (m_offerNum == 2){
          m_offerNum = 6;
          untoggleOthers(6);
        } else {
          m_offerNum = 2;
          untoggleOthers(2);
        }
        m_makeOfferBtn.setEnabled(true);

      };
    });
    m_ourPokes[3].addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        if (m_offerNum == 3){
          m_offerNum = 6;
          untoggleOthers(6);
        } else {
          m_offerNum = 3;
          untoggleOthers(3);
        }
        m_makeOfferBtn.setEnabled(true);

      };
    });
    m_ourPokes[4].addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        if (m_offerNum == 4){
          m_offerNum = 6;
          untoggleOthers(6);
        } else {
          m_offerNum = 4;
          untoggleOthers(4);
        }
       
        m_makeOfferBtn.setEnabled(true);
      };
    });
    m_ourPokes[5].addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        if (m_offerNum == 5){
          m_offerNum = 6;
          untoggleOthers(6);
        } else {
          m_offerNum = 5;
          untoggleOthers(5);
        }
       
        m_makeOfferBtn.setEnabled(true);
      };
    });
   
    //UI Buttons
    m_makeOfferBtn.setText("Make Offer");
    m_makeOfferBtn.setSize(90, 30);
    m_makeOfferBtn.setLocation(90, 10);
    m_makeOfferBtn.setEnabled(false);
    m_makeOfferBtn.addActionListener(m_offerListener);
    getContentPane().add(m_makeOfferBtn);
   
    m_tradeBtn.setText("Trade");
    m_tradeBtn.setEnabled(false);
    m_tradeBtn.setSize(90, 30);
    m_tradeBtn.setLocation(90, 50);
    m_tradeBtn.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent evt) {
        ActionListener yes = new ActionListener(){
          public void actionPerformed(ActionEvent evt) {
            performTrade();
             getDisplay().remove(m_confirm);
            m_confirm = null;
            setVisible(false);
          }
       
        };
        ActionListener no = new ActionListener(){
          public void actionPerformed(ActionEvent evt) {
            m_confirm.setVisible(false);
            getDisplay().remove(m_confirm);
            m_confirm = null;
            setVisible(true);
          }
       
        };
        m_confirm = new ConfirmationDialog("Are you sure you want to trade?", yes, no);
        setVisible(false);
      }
    });
    getContentPane().add(m_tradeBtn);
   
    m_cancelBtn.setText("Cancel Trade");
    m_cancelBtn.setSize(90, 30);
    m_cancelBtn.setLocation(90, 90);
    m_cancelBtn.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent evt) {
        cancelTrade();
      };
    });
    getContentPane().add(m_cancelBtn);
View Full Code Here

        else
          m_categoryButtons[i].setLocation(m_categoryButtons[i - 1]
              .getX() + 65, 10);
        m_categoryButtons[i].setFont(GameClient.getFontLarge());
        m_categoryButtons[i].setOpaque(false);
        m_categoryButtons[i].addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            destroyPopup();
            m_curCategory = j;
            m_update = true;
          }
        });
        getContentPane().add(m_categoryButtons[i]);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    // Bag Image
    Label bagicon = new Label("");
    bagicon.setSize(40, 40);

    LoadingList.setDeferredLoading(true);
    try {
      bagicon.setImage(new Image(respath+"res/ui/bag/front.png", false));
    } catch (SlickException e1) {
    }
    LoadingList.setDeferredLoading(false);

    bagicon.setLocation(18, 0);
    bagicon.setFont(GameClient.getFontLarge());
    getContentPane().add(bagicon);

    // Scrolling Button LEFT
    m_leftButton = new Button("<");
    m_leftButton.setSize(20, 40);
    m_leftButton.setLocation(15, 95);
    m_leftButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        destroyPopup();
        int i = m_scrollIndex.get(m_curCategory) - 1;
        m_scrollIndex.remove(m_curCategory);
        m_scrollIndex.put(m_curCategory, i);
        m_update = true;
      }
    });
    getContentPane().add(m_leftButton);

    // Item Buttons and Stock Labels
    for (int i = 0; i < 4; i++) {
      final int j = i;
      // Starts the item buttons
      Button item = new Button();
      item.setSize(60, 60);
      item.setLocation(50 + (80 * i), 85);
      item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          destroyPopup();
          useItem(j);
        }
      });
      m_itemBtns.add(item);
      getContentPane().add(item);

      // Starts the item labels
      Label stock = new Label();
      stock.setSize(60, 40);
      stock.setLocation(50 + (80 * i), 135);
      stock.setHorizontalAlignment(Label.CENTER_ALIGNMENT);
      stock.setFont(GameClient.getFontLarge());
      stock.setForeground(Color.white);
      m_stockLabels.add(stock);
      getContentPane().add(stock);
    }

    // Scrolling Button Right
    m_rightButton = new Button(">");
    m_rightButton.setSize(20, 40);
    m_rightButton.setLocation(365, 95);
    m_rightButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        destroyPopup();
        int i = m_scrollIndex.get(m_curCategory) + 1;
        m_scrollIndex.remove(m_curCategory);
        m_scrollIndex.put(m_curCategory, i);
        m_update = true;
      }
    });
    getContentPane().add(m_rightButton);

    // Close Button
    m_cancel = new Button("Close");
    m_cancel.setSize(400, 32);
    m_cancel.setLocation(0, 195);
    m_cancel.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        destroyPopup();
        closeBag();
      }
    });
    getContentPane().add(m_cancel);

    // Frame properties
    getResizer().setVisible(false);
    getCloseButton().addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        destroyPopup();
        closeBag();
      }
    });
View Full Code Here

   
    // Use button
    m_use = new Button("Use");
    m_use.setSize(100,25);
    m_use.setLocation(0, m_name.getY() + m_name.getHeight() + 3);
    m_use.addActionListener(new ActionListener(){
      public void actionPerformed (ActionEvent e){
        useItem(m_id, m_useOnPoke, m_isBattle);
      }
    });
    getContentPane().add(m_use);

    if (!isBattle){
      m_give = new Button("Give");
      m_give.setSize(100,25);
      m_give.setLocation(0, m_use.getY() + 25);
      m_give.setEnabled(false);
      m_give.addActionListener(new ActionListener(){
        public void actionPerformed (ActionEvent e){
          giveItem(m_id);
        }
      });
      getContentPane().add(m_give);
    }
    // Destroy the item
    m_destroy = new Button("Drop");
    m_destroy.setSize(100,25);
    if (!isBattle)
      m_destroy.setLocation(0, m_give.getY() + 25);
    else
      m_destroy.setLocation(0, m_use.getY() + 25);
    m_destroy.addActionListener(new ActionListener(){
      public void actionPerformed (ActionEvent e){
        GameClient.getInstance().getPacketGenerator().writeTcpMessage("i" + m_id);
        destroyPopup();
      }
    });
    getContentPane().add(m_destroy);
   
    // Close the popup
    m_cancel = new Button("Cancel");
    m_cancel.setSize(100,25);
    m_cancel.setLocation(0, m_destroy.getY() + 25);
    m_cancel.addActionListener(new ActionListener(){
      public void actionPerformed (ActionEvent e){
        destroyPopup();
      }
    });
    getContentPane().add(m_cancel);
View Full Code Here

     
      m_servers[0] = new Button(in.readLine());
      m_servers[0].setSize(280, 24);
      m_servers[0].setLocation(16, 32);
      m_servers[0].setVisible(true);
      m_servers[0].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
          GameClient.setHost(m_host[0]);
        }
      });
      this.add(m_servers[0]);
      m_host[0] = in.readLine();
     
      m_servers[1] = new Button(in.readLine());
      m_servers[1].setSize(280, 24);
      m_servers[1].setLocation(16, 64);
      m_servers[1].setVisible(true);
      m_servers[1].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
          GameClient.setHost(m_host[1]);
        }
      });
      this.add(m_servers[1]);
      m_host[1] = in.readLine();
     
      m_servers[2] = new Button(in.readLine());
      m_servers[2].setSize(280, 24);
      m_servers[2].setLocation(16, 96);
      m_servers[2].setVisible(true);
      m_servers[2].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
          GameClient.setHost(m_host[2]);
        }
      });
      this.add(m_servers[2]);
      m_host[2] = in.readLine();
     
      m_servers[3] = new Button(in.readLine());
      m_servers[3].setSize(280, 24);
      m_servers[3].setLocation(16, 128);
      m_servers[3].setVisible(true);
      m_servers[3].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
          GameClient.setHost(m_host[3]);
        }
      });
      this.add(m_servers[3]);
      m_host[3] = in.readLine();
     
      m_servers[4] = new Button(in.readLine());
      m_servers[4].setSize(280, 24);
      m_servers[4].setLocation(16, 160);
      m_servers[4].setVisible(true);
      m_servers[4].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
          GameClient.setHost(m_host[4]);
        }
      });
      this.add(m_servers[4]);
      m_host[4] = in.readLine();
     
      /*
       * Finally, check which servers don't exist and disable their buttons
       */
      for(int i = 0; i < 5; i++) {
        if(m_host[i].equalsIgnoreCase("-")) {
          m_servers[i].setEnabled(false);
          m_host[i] = "";
        }
        m_servers[i].setForeground(m_black);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    privateIP = new TextField();
    privateIP.setLocation(16, 204);
    privateIP.setSize(128, 24);
    this.add(privateIP);
   
    privateServer = new Button();
    privateServer.setText(translate.get(2));
    privateServer.setSize(128, 24);
    privateServer.setLocation(168, 204);
    privateServer.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
        GameClient.setHost(getPrivateServer());
      }
    });
    this.add(privateServer);
View Full Code Here

TOP

Related Classes of mdes.slick.sui.event.ActionListener

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.