01: /*
02: * @(#)VsnetCheckBoxMenuItemUI.java
03: *
04: * Copyright 2002 JIDE Software Inc. All rights reserved.
05: */
06: package com.jidesoft.plaf.eclipse;
07:
08: import javax.swing.*;
09: import javax.swing.plaf.ComponentUI;
10: import java.awt.*;
11: import java.awt.event.MouseEvent;
12:
13: /**
14: * CheckboxMenuItem UI implementation.
15: */
16: public class EclipseCheckBoxMenuItemUI extends EclipseMenuItemUI {
17:
18: public static ComponentUI createUI(JComponent c) {
19: return new EclipseCheckBoxMenuItemUI();
20: }
21:
22: @Override
23: protected String getPropertyPrefix() {
24: return "CheckBoxMenuItem";
25: }
26:
27: public void processMouseEvent(JMenuItem item, MouseEvent e,
28: MenuElement path[], MenuSelectionManager manager) {
29: Point p = e.getPoint();
30: if (p.x >= 0 && p.x < item.getWidth() && p.y >= 0
31: && p.y < item.getHeight()) {
32: if (e.getID() == MouseEvent.MOUSE_RELEASED) {
33: manager.clearSelectedPath();
34: item.doClick(0);
35: } else
36: manager.setSelectedPath(path);
37: } else if (item.getModel().isArmed()) {
38: MenuElement newPath[] = new MenuElement[path.length - 1];
39: int i, c;
40: for (i = 0, c = path.length - 1; i < c; i++)
41: newPath[i] = path[i];
42: manager.setSelectedPath(newPath);
43: }
44: }
45: }
|