try {
allImage = ImageIO.read(allIconURL);
} catch (IOException ex) {
Logger.getLogger(UserSelector.class.getName()).log(Level.SEVERE, null, ex);
}
userList.add(0, new User(HTMLTextEditor.allStr, allImage));
// remove the user himself
String selfname = ChatroomClient.getClient().getUserName();
for (int i = 0; i < userList.size(); i++) {
if (userList.get(i).getName().equals(selfname)) {
userList.remove(i);
break;
}
}
final JList selectList = new JList(userList.toArray());
selectList.setCellRenderer(new UserRenderer());
//selectList.setLayout(new GridLayout(0,6));
selectList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
selectList.setVisibleRowCount(-1);
selectList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
int index = selectList.locationToIndex(e.getPoint());
User u = (User) selectList.getModel().getElementAt(index);
UserSelector.this.finialize(u.getName());
}
}
});
JScrollPane scrollPane = new JScrollPane(selectList);
//selectPanel.setLayout(new GridLayout(0,6));