1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
1088 MenuElement path[] = e.getPath();
1089 Point p = e.getPoint();
1090 if (p.x >= 0 && p.x < menuItem.getWidth() &&
1091 p.y >= 0 && p.y < menuItem.getHeight()) {
1092 doClick(manager);
1093 } else {
1094 manager.clearSelectedPath();
1095 }
1096 }
1097
1098
1099 //
1100 // PropertyChangeListener
1101 //
1102 public void propertyChange(PropertyChangeEvent e) {
1103 String name = e.getPropertyName();
1104
1105 if (name == "labelFor" || name == "displayedMnemonic" ||
1106 name == "accelerator") {
1107 updateAcceleratorBinding();
1108 } else if (name == "text" || "font" == name ||
1109 "foreground" == name ||
1110 "ancestor" == name || "graphicsConfiguration" == name) {
1111 // remove the old html view client property if one
1112 // existed, and install a new one if the text installed
1113 // into the JLabel is html source.
1114 JMenuItem lbl = ((JMenuItem) e.getSource());
1115 String text = lbl.getText();
1116 BasicHTML.updateRenderer(lbl, text);
1117 } else if (name == "iconTextGap") {
1118 defaultTextIconGap = ((Number)e.getNewValue()).intValue();
1119 } else if (name == "horizontalTextPosition") {
1120 updateCheckIcon();
1121 }
1122 }
1123 }
1124 }
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
1088 MenuElement path[] = e.getPath();
1089 Point p = e.getPoint();
1090 if (p.x >= 0 && p.x < menuItem.getWidth() &&
1091 p.y >= 0 && p.y < menuItem.getHeight()) {
1092 doClick(manager);
1093 } else {
1094 manager.clearSelectedPath();
1095 }
1096 }
1097
1098
1099 //
1100 // PropertyChangeListener
1101 //
1102 public void propertyChange(PropertyChangeEvent e) {
1103 String name = e.getPropertyName();
1104
1105 if (name == "labelFor" || name == "displayedMnemonic" ||
1106 name == "accelerator") {
1107 updateAcceleratorBinding();
1108 } else if (name == "text" || "font" == name || "foreground" == name
1109 || "graphicsConfiguration" == name) {
1110 // remove the old html view client property if one
1111 // existed, and install a new one if the text installed
1112 // into the JLabel is html source.
1113 JMenuItem lbl = ((JMenuItem) e.getSource());
1114 String text = lbl.getText();
1115 BasicHTML.updateRenderer(lbl, text);
1116 } else if (name == "iconTextGap") {
1117 defaultTextIconGap = ((Number)e.getNewValue()).intValue();
1118 } else if (name == "horizontalTextPosition") {
1119 updateCheckIcon();
1120 }
1121 }
1122 }
1123 }
|