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);