public void actionPerformed(ActionEvent ae) { if (ae.getActionCommand().equals("Add User")) { jta.append("\n" + userId.getText()); User user = new User(userId.getText()); } else if (ae.getActionCommand().equals("Add Group")) { jta.append("\n" + groupId.getText()); Group group = new Group(groupId.getText()); } else if (ae.getActionCommand().equals("Open User View")) { try { if (!jta.getSelectedText().equals("null")) { userView.setVisible(true); } } catch (Exception e) { JOptionPane.showMessageDialog( frame, "Nothing selected", "Error", JOptionPane.ERROR_MESSAGE); } } else if (ae.getActionCommand().equals("Show User Total")) { JOptionPane.showMessageDialog(frame, User.getUserTotal()); } else if (ae.getActionCommand().equals("Show Group Total")) { JOptionPane.showMessageDialog(frame, Group.getGroupTotal()); } else if (ae.getActionCommand().equals("Show Messages Total")) { JOptionPane.showMessageDialog(frame, User.getMessageTotal()); } else if (ae.getActionCommand().equals("Show Positive Percentage")) { String[] newsFeed = User.getNewsFeed(); int positive = 0; int i = 0; while (!(newsFeed[i] == null)) { if (newsFeed[i].contains("good") || newsFeed[i].contains("great") || newsFeed[i].contains("excellent")) positive++; i++; } JOptionPane.showMessageDialog(frame, positive * 100.0 / i + "%"); } else if (ae.getActionCommand().equals("Follow User")) { following.append("\n" + userId2.getText()); } else if (ae.getActionCommand().equals("Post Tweet")) { User.postTweet(tweet.getText()); newsFeed.append("\n" + jta.getSelectedText() + ": " + tweet.getText()); } }