Skip to content
Browse files

popup menu and select background colour

  • Loading branch information...
1 parent 582eb23 commit d2ff54aedff6d01643133dde5c5743fdf562eb35 @maandree committed Apr 18, 2012
Showing with 40 additions and 1 deletion.
  1. +40 −1 src/cnt/interfaces/gui/UserList.java
View
41 src/cnt/interfaces/gui/UserList.java
@@ -44,19 +44,58 @@ public UserList()
this.setBackground(Color.BLACK);
pane.setBackground(Color.BLACK);
this.list.setBackground(Color.BLACK);
+ this.list.setSelectionBackground(new Color(16, 16, 100));
+
+ this.popup = new JPopupMenu();
+ this.popup.add(this.menuFriend = new JMenuItem("Add to friend list"));
+
+
+ this.list.addMouseListener(new MouseAdapter()
+ {
+ /**
+ * {@inheritDoc}
+ */
+ public void mouseReleased(final MouseEvent e)
+ {
+ // e.isPopupTrigger() returns false
+ if (e.getButton() == 3 /*right*/)
+ UserList.this.popup.show(e.getComponent(), e.getX(), e.getY());
+ }
+ });
+
+ this.menuFriend.addActionListener(new ActionListener()
+ {
+ /**
+ * {@inheritDoc}
+ */
+ public void actionPerformed(final ActionEvent e)
+ {
+ System.err.println("[Add to friend list] click");
+ }
+ });
}
/**
* The list component
*/
- private final JList list;
+ private final JList list; // Generics was added to JList in Java 7. We can not use it because CSC only have Java 6 installed.
/**
* The list's model
*/
private final DefaultListModel model;
+ /**
+ * The popup menu
+ */
+ private final JPopupMenu popup;
+
+ /**
+ * The “Add to friend list” menu item
+ */
+ private final JMenuItem menuFriend;
+
}

0 comments on commit d2ff54a

Please sign in to comment.
Something went wrong with that request. Please try again.