private void analyzeSSIDButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_analyzeSSIDButtonActionPerformed
        try
        {
            if (conn == null)
                throw new NullPointerException("No connection to database!");
            
            ResultSet rs;
            ArrayList<String> selectedSSIDList = (ArrayList)ssidList.getSelectedValuesList();
            ArrayList<String> tempMACList = new ArrayList<>(), intersectedMACList = new ArrayList<>(), temp = new ArrayList<>();
            String selectMACsWithSSID="";
            
            Statement st = conn.createStatement();
            for (String ssid : selectedSSIDList)
            {
                selectMACsWithSSID = "SELECT DISTINCT(source) AS Device FROM `requests` WHERE ssid = '"+ ssid.substring(ssid.indexOf("-")+1)+"';";
                rs = st.executeQuery(selectMACsWithSSID);
                while (rs.next()) //get MAC addresses from SSID
                    tempMACList.add(rs.getString(1));
                for (String mac : tempMACList) //foreach mac from last SSID
                    if(!intersectedMACList.isEmpty()) //if intersected is empty (usually first iteration)
                        if(!intersectedMACList.contains(mac)) //if intersected does not contain MAC from last SSID
                            temp.add(mac); //that means it can not be in Intersection
                tempMACList.removeAll(temp); //so we remove it from our last SSID list
                intersectedMACList.clear();
                intersectedMACList.addAll(tempMACList); // which becomes intersection
                tempMACList.clear(); temp.clear();
            }
            
            DefaultListModel<String> listOfMACs = new DefaultListModel();
            for (String mac : intersectedMACList)
                listOfMACs.addElement(mac);
            macList.setModel(listOfMACs);
            
        } catch (NullPointerException e) {
            JOptionPane.showMessageDialog(this, e.getMessage(), "Error!", JOptionPane.ERROR_MESSAGE);
            this.dispose();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, e.getMessage(), "Error!", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_analyzeSSIDButtonActionPerformed