1. /*
  2. * @(#)BasicRadioButtonMenuItemUI.java 1.44 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.plaf.basic;
  8. import javax.swing.*;
  9. import java.awt.*;
  10. import java.awt.event.*;
  11. import javax.swing.plaf.*;
  12. import javax.swing.border.*;
  13. /**
  14. * BasicRadioButtonMenuItem implementation
  15. *
  16. * @version 1.44 01/23/03
  17. * @author Georges Saab
  18. * @author David Karlton
  19. */
  20. public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
  21. {
  22. public static ComponentUI createUI(JComponent b) {
  23. return new BasicRadioButtonMenuItemUI();
  24. }
  25. protected String getPropertyPrefix() {
  26. return "RadioButtonMenuItem";
  27. }
  28. public void processMouseEvent(JMenuItem item,MouseEvent e,MenuElement path[],MenuSelectionManager manager) {
  29. Point p = e.getPoint();
  30. if(p.x >= 0 && p.x < item.getWidth() &&
  31. p.y >= 0 && p.y < item.getHeight()) {
  32. if(e.getID() == MouseEvent.MOUSE_RELEASED) {
  33. manager.clearSelectedPath();
  34. item.doClick(0);
  35. item.setArmed(false);
  36. } else
  37. manager.setSelectedPath(path);
  38. } else if(item.getModel().isArmed()) {
  39. MenuElement newPath[] = new MenuElement[path.length-1];
  40. int i,c;
  41. for(i=0,c=path.length-1;i<c;i++)
  42. newPath[i] = path[i];
  43. manager.setSelectedPath(newPath);
  44. }
  45. }
  46. }