001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui; 003 004import java.awt.Graphics; 005 006import javax.swing.JComponent; 007import javax.swing.plaf.ComponentUI; 008import javax.swing.plaf.metal.MetalToolTipUI; 009 010import org.openstreetmap.josm.tools.Logging; 011 012/** 013 * Overrides MetalToolTipUI to workaround <a href="https://bugs.openjdk.java.net/browse/JDK-8262085">JDK-8262085</a> 014 * @since 17681 015 */ 016public class JosmMetalToolTipUI extends MetalToolTipUI { 017 018 static final JosmMetalToolTipUI sharedInstance = new JosmMetalToolTipUI(); 019 020 /** 021 * Returns an instance of the {@code JosmMetalToolTipUI}. 022 * 023 * @param c a component 024 * @return an instance of the {@code JosmMetalToolTipUI}. 025 */ 026 public static ComponentUI createUI(JComponent c) { 027 return sharedInstance; 028 } 029 030 @Override 031 public void paint(Graphics g, JComponent c) { 032 try { 033 super.paint(g, c); 034 } catch (IllegalArgumentException e) { 035 if ("Width and height must be >= 0".equals(e.getMessage())) { 036 Logging.debug(e); 037 } else { 038 throw e; 039 } 040 } 041 } 042}