Changeset 8075 in josm
- Timestamp:
- 2015-02-16T21:47:42+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r8072 r8075 804 804 } 805 805 806 private int getMaximumAvailableWidth() { 807 int maxWidth = getSize().width; 808 for (int i = 0; i < getMenuCount(); i++) { 809 JMenu menu = getMenu(i); 810 if (menu != null) { 811 maxWidth -= menu.getPreferredSize().width; 812 } 813 } 814 return maxWidth; 815 } 816 806 817 /** 807 818 * Create search field. 808 819 */ 809 820 private JComponent createSearchField() { 810 DisableShortcutsOnFocusGainedTextField searchField = new DisableShortcutsOnFocusGainedTextField(); 821 DisableShortcutsOnFocusGainedTextField searchField = new DisableShortcutsOnFocusGainedTextField() { 822 @Override 823 public Dimension getPreferredSize() { 824 // JMenuBar uses a BoxLayout and it doesn't seem possible to specify a size factor, 825 // so compute the preferred size dynamically 826 return new Dimension(Math.min(200, Math.max(25, getMaximumAvailableWidth())), 827 helpMenu.getPreferredSize().height); 828 } 829 }; 811 830 searchField.setEditable(true); 812 Dimension d = new Dimension(200, helpMenu.getPreferredSize().height); 813 searchField.setPreferredSize(d); 814 searchField.setMaximumSize(d); 831 searchField.setMaximumSize(new Dimension(200, helpMenu.getPreferredSize().height)); 815 832 searchField.setHint(tr("Search menu items")); 816 833 searchField.setToolTipText(tr("Search menu items"));
Note:
See TracChangeset
for help on using the changeset viewer.