01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package javax.swing;
19:
20: import org.apache.harmony.x.swing.internal.nls.Messages;
21:
22: /**
23: * <p>
24: * <i>ComponentInputMap</i>
25: * </p>
26: * <h3>Implementation Notes:</h3>
27: * <ul>
28: * <li>The <code>serialVersionUID</code> fields are explicitly declared as a performance
29: * optimization, not as a guarantee of serialization compatibility.</li>
30: * </ul>
31: */
32: public class ComponentInputMap extends InputMap {
33: private static final long serialVersionUID = 1760753505284728053L;
34:
35: private JComponent component;
36:
37: public ComponentInputMap(JComponent component) {
38: if (component == null) {
39: throw new IllegalArgumentException(Messages
40: .getString("swing.57")); //$NON-NLS-1$
41: }
42: this .component = component;
43: }
44:
45: @Override
46: public void put(KeyStroke keyStroke, Object key) {
47: super .put(keyStroke, key);
48: if (component != null) {
49: component.componentInputMapChanged(this );
50: }
51: }
52:
53: @Override
54: public void remove(KeyStroke keyStroke) {
55: super .remove(keyStroke);
56: component.componentInputMapChanged(this );
57: }
58:
59: public JComponent getComponent() {
60: return component;
61: }
62:
63: @Override
64: public void setParent(InputMap parent) {
65: if (parent != null
66: && (!(parent instanceof ComponentInputMap) || (((ComponentInputMap) parent)
67: .getComponent() != component))) {
68: throw new IllegalArgumentException(Messages
69: .getString("swing.4D")); //$NON-NLS-1$
70: }
71: super .setParent(parent);
72: if (component != null) {
73: component.componentInputMapChanged(this );
74: }
75: }
76:
77: @Override
78: public void clear() {
79: super.clear();
80: component.componentInputMapChanged(this);
81: }
82: }
|