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: * @author Sergey Burlak
19: * @version $Revision$
20: */package javax.swing;
21:
22: import javax.accessibility.Accessible;
23: import javax.accessibility.AccessibleContext;
24: import javax.accessibility.AccessibleRole;
25: import javax.swing.plaf.ToolTipUI;
26:
27: import org.apache.harmony.x.swing.internal.nls.Messages;
28:
29: public class JToolTip extends JComponent implements Accessible {
30: private static final String COMPONENT = "component";
31: private static final String TIP_TEXT = "tiptext";
32: private String tipText;
33: private JComponent comp;
34:
35: protected class AccessibleJToolTip extends AccessibleJComponent {
36: public String getAccessibleDescription() {
37: throw new UnsupportedOperationException(Messages
38: .getString("swing.27")); //$NON-NLS-1$
39: }
40:
41: public AccessibleRole getAccessibleRole() {
42: throw new UnsupportedOperationException(Messages
43: .getString("swing.27")); //$NON-NLS-1$
44: }
45: }
46:
47: public JToolTip() {
48: updateUI();
49: }
50:
51: public ToolTipUI getUI() {
52: return (ToolTipUI) ui;
53: }
54:
55: public void updateUI() {
56: setUI((ToolTipUI) UIManager.getUI(this ));
57: }
58:
59: public String getUIClassID() {
60: return "ToolTipUI";
61: }
62:
63: public void setTipText(final String tipText) {
64: if (tipText != this .tipText
65: || (tipText != null && !tipText.equals(this .tipText))) {
66: String oldValue = this .tipText;
67: this .tipText = tipText;
68: firePropertyChange(TIP_TEXT, oldValue, tipText);
69: }
70: }
71:
72: public String getTipText() {
73: return tipText;
74: }
75:
76: public void setComponent(final JComponent c) {
77: if (c != comp) {
78: JComponent oldValue = comp;
79: comp = c;
80: firePropertyChange(COMPONENT, oldValue, c);
81: }
82: }
83:
84: public JComponent getComponent() {
85: return comp;
86: }
87:
88: public AccessibleContext getAccessibleContext() {
89: if (accessibleContext == null) {
90: accessibleContext = new AccessibleJToolTip();
91: }
92:
93: return accessibleContext;
94: }
95: }
|