equal
deleted
inserted
replaced
56 |
56 |
57 static MetalToolTipUI sharedInstance = new MetalToolTipUI(); |
57 static MetalToolTipUI sharedInstance = new MetalToolTipUI(); |
58 private Font smallFont; |
58 private Font smallFont; |
59 // Refer to note in getAcceleratorString about this field. |
59 // Refer to note in getAcceleratorString about this field. |
60 private JToolTip tip; |
60 private JToolTip tip; |
|
61 |
|
62 /** |
|
63 * The space between strings. |
|
64 */ |
61 public static final int padSpaceBetweenStrings = 12; |
65 public static final int padSpaceBetweenStrings = 12; |
62 private String acceleratorDelimiter; |
66 private String acceleratorDelimiter; |
63 |
67 |
|
68 /** |
|
69 * Constructs an instance of the {@code MetalToolTipUI}. |
|
70 */ |
64 public MetalToolTipUI() { |
71 public MetalToolTipUI() { |
65 super(); |
72 super(); |
66 } |
73 } |
67 |
74 |
|
75 /** |
|
76 * Returns an instance of the {@code MetalToolTipUI}. |
|
77 * |
|
78 * @param c a component |
|
79 * @return an instance of the {@code MetalToolTipUI}. |
|
80 */ |
68 public static ComponentUI createUI(JComponent c) { |
81 public static ComponentUI createUI(JComponent c) { |
69 return sharedInstance; |
82 return sharedInstance; |
70 } |
83 } |
71 |
84 |
72 public void installUI(JComponent c) { |
85 public void installUI(JComponent c) { |
146 d.width += calcAccelSpacing(c, c.getFontMetrics(smallFont), key); |
159 d.width += calcAccelSpacing(c, c.getFontMetrics(smallFont), key); |
147 } |
160 } |
148 return d; |
161 return d; |
149 } |
162 } |
150 |
163 |
|
164 /** |
|
165 * If the accelerator is hidden, the method returns {@code true}, |
|
166 * otherwise, returns {@code false}. |
|
167 * |
|
168 * @return {@code true} if the accelerator is hidden. |
|
169 */ |
151 protected boolean isAcceleratorHidden() { |
170 protected boolean isAcceleratorHidden() { |
152 Boolean b = (Boolean)UIManager.get("ToolTip.hideAccelerator"); |
171 Boolean b = (Boolean)UIManager.get("ToolTip.hideAccelerator"); |
153 return b != null && b.booleanValue(); |
172 return b != null && b.booleanValue(); |
154 } |
173 } |
155 |
174 |
160 |
179 |
161 this.tip = null; |
180 this.tip = null; |
162 return retValue; |
181 return retValue; |
163 } |
182 } |
164 |
183 |
|
184 /** |
|
185 * Returns the accelerator string. |
|
186 * |
|
187 * @return the accelerator string. |
|
188 */ |
165 // NOTE: This requires the tip field to be set before this is invoked. |
189 // NOTE: This requires the tip field to be set before this is invoked. |
166 // As MetalToolTipUI is shared between all JToolTips the tip field is |
190 // As MetalToolTipUI is shared between all JToolTips the tip field is |
167 // set appropriately before this is invoked. Unfortunately this means |
191 // set appropriately before this is invoked. Unfortunately this means |
168 // that subclasses that randomly invoke this method will see varying |
192 // that subclasses that randomly invoke this method will see varying |
169 // results. If this becomes an issue, MetalToolTipUI should no longer be |
193 // results. If this becomes an issue, MetalToolTipUI should no longer be |