442 if (windowInputMap != null) {
443 windowInputMap.clear();
444 }
445 if (accelerator != null) {
446 if (windowInputMap == null) {
447 windowInputMap = createInputMap(JComponent.
448 WHEN_IN_FOCUSED_WINDOW);
449 SwingUtilities.replaceUIInputMap(menuItem,
450 JComponent.WHEN_IN_FOCUSED_WINDOW, windowInputMap);
451 }
452 windowInputMap.put(accelerator, "doClick");
453 }
454 }
455
456 public Dimension getMinimumSize(JComponent c) {
457 Dimension d = null;
458 View v = (View) c.getClientProperty(BasicHTML.propertyKey);
459 if (v != null) {
460 d = getPreferredSize(c);
461 d.width -= v.getPreferredSpan(View.X_AXIS) - v.getMinimumSpan(View.X_AXIS);
462 }
463 return d;
464 }
465
466 public Dimension getPreferredSize(JComponent c) {
467 return getPreferredMenuItemSize(c,
468 checkIcon,
469 arrowIcon,
470 defaultTextIconGap);
471 }
472
473 public Dimension getMaximumSize(JComponent c) {
474 Dimension d = null;
475 View v = (View) c.getClientProperty(BasicHTML.propertyKey);
476 if (v != null) {
477 d = getPreferredSize(c);
478 d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
479 }
480 return d;
481 }
482
|
442 if (windowInputMap != null) {
443 windowInputMap.clear();
444 }
445 if (accelerator != null) {
446 if (windowInputMap == null) {
447 windowInputMap = createInputMap(JComponent.
448 WHEN_IN_FOCUSED_WINDOW);
449 SwingUtilities.replaceUIInputMap(menuItem,
450 JComponent.WHEN_IN_FOCUSED_WINDOW, windowInputMap);
451 }
452 windowInputMap.put(accelerator, "doClick");
453 }
454 }
455
456 public Dimension getMinimumSize(JComponent c) {
457 Dimension d = null;
458 View v = (View) c.getClientProperty(BasicHTML.propertyKey);
459 if (v != null) {
460 d = getPreferredSize(c);
461 d.width -= v.getPreferredSpan(View.X_AXIS) - v.getMinimumSpan(View.X_AXIS);
462 } else if (c.getParent() instanceof JMenuBar) {
463 //if the menu is a toplevel item, then return preferred size.
464 d = getPreferredSize(c);
465 }
466
467 return d;
468 }
469
470 public Dimension getPreferredSize(JComponent c) {
471 return getPreferredMenuItemSize(c,
472 checkIcon,
473 arrowIcon,
474 defaultTextIconGap);
475 }
476
477 public Dimension getMaximumSize(JComponent c) {
478 Dimension d = null;
479 View v = (View) c.getClientProperty(BasicHTML.propertyKey);
480 if (v != null) {
481 d = getPreferredSize(c);
482 d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
483 }
484 return d;
485 }
486
|