Set ToolTipText background color

Complete source code below, will show you how to set ToolTipText background color.

**************************************************************************
COMPLETE SOURCE CODE FOR : SetToolTipTextBackgroundColor.java
**************************************************************************


import javax.swing.UIManager;
import javax.swing.JFrame;
import javax.swing.JButton;

import java.awt.FlowLayout;
import java.awt.Color;

public class SetToolTipTextBackgroundColor
{
/**
*Create a button with text ( Put your cursor on me )
*/
JButton button=new JButton("Put your cursor on me");

//Create a window using JFrame with text ( Set ToolTipText background color )
JFrame frame=new JFrame("Set ToolTipText background color");

public SetToolTipTextBackgroundColor()
{
//Create a color base on RGB value
//You can get your color value base on RGB using Color picker at above
//R=204 G=0 B=153
Color backgroundColor=new Color(204,0,153);

//Create UIManager
UIManager uim=new UIManager();

//Set tooltiptext background color using created Color
uim.put("ToolTip.background",backgroundColor);

//Set tooltiptext for created button
button.setToolTipText("I am a button");

frame.setLayout(new FlowLayout());
frame.add(button);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,400);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

public static void main(String[]args)
{
SetToolTipTextBackgroundColor stttbc=new SetToolTipTextBackgroundColor();
}
}


**************************************************************************
JUST COMPILE AND EXECUTE IT
**************************************************************************

Set ToolTipText text font

Complete source code below, will show you how to set ToolTipText text font.

************************************************************************
COMPLETE SOURCE CODE FOR : SetToolTipTextFont.java
************************************************************************


import javax.swing.UIManager;
import javax.swing.JFrame;
import javax.swing.JButton;

import java.awt.FlowLayout;
import java.awt.Font;

public class SetToolTipTextFont
{
/**
*Create a button with text ( Put your cursor on me )
*/
JButton button=new JButton("Put your cursor on me");

//Create a window using JFrame with text ( Set ToolTipText text font )
JFrame frame=new JFrame("Set ToolTipText text font");

public SetToolTipTextFont()
{
//Create a font :
//Name : Verdana
//Style : Bold
//Size : 20
Font textFont=new Font("Verdana",Font.BOLD,20);

//Create UIManager
UIManager uim=new UIManager();

//Set tooltiptext text font using created Font
uim.put("ToolTip.font",textFont);

//Set tooltiptext for created button
button.setToolTipText("I am a button");

frame.setLayout(new FlowLayout());
frame.add(button);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,400);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

public static void main(String[]args)
{
SetToolTipTextFont stttf=new SetToolTipTextFont();
}
}


************************************************************************
JUST COMPILE AND EXECUTE IT
************************************************************************

Set ToolTipText text color

Complete source code below, will show you how to set ToolTipText text color.

************************************************************************
COMPLETE SOURCE CODE FOR : SetToolTipTextColor.java
************************************************************************


import javax.swing.UIManager;
import javax.swing.JFrame;
import javax.swing.JButton;

import java.awt.FlowLayout;
import java.awt.Color;

public class SetToolTipTextColor
{
/**
*Create a button with text ( Put your cursor on me )
*/
JButton button=new JButton("Put your cursor on me");

//Create a window using JFrame with title ( Set ToolTipText text color )
JFrame frame=new JFrame("Set ToolTipText text color");

public SetToolTipTextColor()
{
//Create a color base on RGB value
//You can get your color value base on RGB using Color picker at above
//R=255 G=255 B=255 is RGB value for white
Color textColor=new Color(255,255,255);

//Create UIManager
UIManager uim=new UIManager();

//Set tooltiptext text color using created Color
uim.put("ToolTip.foreground",textColor);

//Set tooltiptext for created button
//So, it's tooltiptext text color will be WHITE
button.setToolTipText("I am a button");

frame.setLayout(new FlowLayout());
frame.add(button);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,400);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

public static void main(String[]args)
{
SetToolTipTextColor stttc=new SetToolTipTextColor();
}
}


************************************************************************
JUST COMPILE AND EXECUTE IT
************************************************************************

RELAXING NATURE VIDEO