![JAR search and dependency download from the Maven repository](/logo.png)
freeseawind.lf.basic.toolips.LuckToolTipUI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of littleluck Show documentation
Show all versions of littleluck Show documentation
Java Swing cross platform LookAndFeel
package freeseawind.lf.basic.toolips;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicToolTipUI;
import freeseawind.lf.utils.LuckUtils;
import freeseawind.ninepatch.swing.SwingNinePatch;
/**
*
* ToolTipUI实现类,设置UI组件为不完全透明,使用点九图作为背景和边框。
*
*
* A ToolTipUI implementation class, set UI components are not fully transparent,
* to use as a background in ninepatch image, using an empty border to keep the
* content of the pitch.
*
*
* See Also:{@link LuckToolipUIBundle}
*
*
* @author freeseawind@github
* @version 1.0
*
*/
public class LuckToolTipUI extends BasicToolTipUI
{
private static LuckToolTipUI sharedInstance = new LuckToolTipUI();
private SwingNinePatch np;
public static ComponentUI createUI(JComponent c)
{
return sharedInstance;
}
public void installUI(JComponent c)
{
super.installUI(c);
if(np == null)
{
np = LuckUtils.createNinePatch(LuckToolipUIBundle.BGIMG);
}
}
@Override
public void uninstallUI(JComponent c)
{
super.uninstallUI(c);
np = null;
}
public void installDefaults(JComponent c)
{
super.installDefaults(c);
c.setOpaque(false);
}
public void paint(Graphics g, JComponent c)
{
if(np != null)
{
np.drawNinePatch((Graphics2D) g, 0, 0, c.getWidth(), c.getHeight());
}
super.paint(g, c);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy