List of usage examples for javax.swing JMenuItem setModel
public void setModel(ButtonModel newModel)
From source file:org.eclipse.birt.chart.device.swing.SwingEventHandler.java
/** * @param muv/*from w w w. ja v a 2 s . co m*/ * @param point */ private void openMultiULRs(MultiURLValues muv, Point point) { if (popupMenu != null && popupMenu.isValid()) { // Remove previous menu object. popupMenu.setVisible(false); ((JComponent) iun.peerInstance()).remove(popupMenu); } popupMenu = new JPopupMenu(); // Create popup menu items. for (URLValue uv : muv.getURLValues()) { JMenuItem menuItem = new JMenuItem(); popupMenu.add(menuItem); menuItem.setText(uv.getLabel().getCaption().getValue()); if (uv.getTooltip() != null && uv.getTooltip().length() > 0) menuItem.setToolTipText(uv.getTooltip()); URLMenuItemModel uim = new URLMenuItemModel(); uim.setURLValue(uv); menuItem.setModel(uim); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { URLValue urlValue = ((URLMenuItemModel) ((JMenuItem) e.getSource()).getModel()).getURLValue(); openURL(urlValue); } }); } // Show menu. popupMenu.show((JComponent) iun.peerInstance(), point.x, point.y); }