Changeset 2208 in josm
- Timestamp:
- 2009-09-28T12:50:05+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetMenu.java
r2140 r2208 29 29 super.setIcon(iconName); 30 30 } 31 32 private Component copyMenuComponent(Component menuComponent) { 33 if (menuComponent instanceof JMenu) { 34 JMenu menu = (JMenu)menuComponent; 35 JMenu result = new JMenu(menu.getAction()); 36 for (Component item:menu.getMenuComponents()) { 37 result.add(copyMenuComponent(item)); 38 } 39 result.setText(menu.getText()); 40 return result; 41 } else if (menuComponent instanceof JMenuItem) { 42 JMenuItem menuItem = (JMenuItem)menuComponent; 43 JMenuItem result = new JMenuItem(menuItem.getAction()); 44 result.setText(menuItem.getText()); 45 return result; 46 } else if(menuComponent instanceof JSeparator) { 47 return new JSeparator(); 48 } else { 49 return menuComponent; 50 } 51 } 52 31 53 public void actionPerformed(ActionEvent e) { 32 54 Object s = e.getSource(); … … 36 58 JPopupMenu pm = new JPopupMenu(getName()); 37 59 for(Component c : menu.getMenuComponents()) 60 pm.add(copyMenuComponent(c)); 38 61 { 39 if(c instanceof JMenuItem)40 {41 JMenuItem j = new JMenuItem(((JMenuItem)c).getAction());42 j.setText(((JMenuItem)c).getText());43 pm.add(j);44 }45 else if(c instanceof JSeparator)46 pm.addSeparator();47 62 } 48 63 pm.show(co, co.getWidth()/2, co.getHeight()/2);
Note:
See TracChangeset
for help on using the changeset viewer.