JFrame frame = new JFrame("PopUpColorMenu v2.0");
JPanel panel = new JPanel();
JButton button = new JButton("Uno");
button.setInheritsPopupMenu(true);
panel.add(button);
button = new JButton("Due");
button.setInheritsPopupMenu(true);
panel.add(button);
button = new JButton("Tre");
button.setInheritsPopupMenu(true);
panel.add(button);
final JPopupMenu colorMenu = new JPopupMenu("Color");
colorMenu.add(makeMenuItem("Red"));
colorMenu.add(makeMenuItem("Green"));
colorMenu.add(makeMenuItem("Blue"));
panel.setComponentPopupMenu( colorMenu );
panel.setBackground(Color.BLUE);
frame.add( BorderLayout.CENTER, panel );
frame.setSize(200,50);
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setVisible(true);