rendered paste bodypackage edu.psu.ist.ist311.groupproj;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
//*******************************
//Name: Team Swag
//IST 311.001
//December 06, 2007
//formats buddy list
//
//Class: BuddyList
//*******************************
public class BuddyList extends JPanel implements ActionListener{
private JButton addBuddy, removeBuddy, logOut; //buttons to add/remove buddy and log out
private JTextArea buddySpace; //area in which buddy list is displayed
private JScrollPane buddySP; //scroll pane for buddy list to be displayed within
private Client client;
imJFrame imjf;
public BuddyList(imJFrame imjf, Client client)
{
super();
//client
this.client = client;
//get control of the frame
this.imjf = imjf;
//defines background and layout
this.setLayout(new FlowLayout());
//button for add buddy
addBuddy = new JButton("Add Buddy");
addBuddy.setBounds (new Rectangle(10,540,120,20));
addBuddy.addActionListener(this);
this.add(addBuddy);
//button for remove buddy
removeBuddy = new JButton("Remove Buddy");
removeBuddy.setBounds(new Rectangle(120,540,130,20));
removeBuddy.addActionListener(this);
this.add(removeBuddy);
//button for log out
logOut = new JButton("Log Out");
logOut.setBounds(new Rectangle(10,570,100,20));
logOut.addActionListener(this);
this.add(logOut);
}
public void addBuddies()
{
repaint();
}
public void actionPerformed(ActionEvent event){
Object obj = event.getSource();
if(obj == logOut)
{
client.logOut();
}
if(obj == addBuddy)
{
this.add(new JButton("test"));
//String input = JOptionPane.showInputDialog("Enter buddy to be added");
this.repaint();
//System.out.println(input);
}
if(obj == removeBuddy)
{
String input = JOptionPane.showInputDialog("Enter buddy to be removed");
}
}
}