Currently Selected User

I am sure this is so easy but I searched and wasn’t able to find anything but I just can’t seem to figure out how to get the currently selected user from with this code (not too mention I am an extreme Java neophyte!):

final Action sayHelloAction = new AbstractAction() {
            public void actionPerformed(ActionEvent actionEvent) {
                //string to store the selected user
                String selectedUser = "";                 ....code to find the currently "clicked" or selectedUser....                  //temporarily print out the selectedUser for testing
                JOptionPane.showMessageDialog(SparkManager.getMainWindow(), selectedUser);
                //send fullJID to another function             }
};

Thanks in advance!

Hi Brandon,

You can do the following to get the selected user(s):

Collection selectedUsers = SparkManager.getWorkspace().getContactList().getSelectedUsers();

Hope that helps,

Ryan

Hey Ryan,

Thanks for your quick response. I already had a ContactItem object sent to the function I was working with. I was trying to use contact.getFullJID(); which wasn’t returning anything. I finally updated my Spark libraries from within the Sparkplug directory and used contact.getJID(); to get the selected user I wanted – duh I should have done this a long time ago.

Brandon