Pages

Tool tip text

Tool tip text is a description about a component. For example, about a button in a graphical user interface. A tool tip text will appear when you hover and stop for certain time on the button.

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


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

public class ToolTipText
{
public static void main(String[]args)
{
//Create a button with text ( Hover on me and don't move )
JButton button=new JButton("Hover on me and don't move");

//SET TOOL TIP TEXT TO THE BUTTON
//Text : I am tool tip text
button.setToolTipText("I am tool tip text");

//Create a JFrame with title ( Tool tip text )
JFrame frame=new JFrame("Tool tip text");

//Add created button into JFrame
frame.add(button);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(250,65);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JRadioButton text bold and italic

Source code below will show you, how to set JRadioButton text to bold and italic.

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


import javax.swing.JRadioButton;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJRadioButtonTextBoldAndItalic
{
public static void main(String[]args)
{
//Create radio button using JRadioButton with text ( I am a radio button )
JRadioButton radioButton=new JRadioButton("I am a radio button");

//Create font.
//Font Name : Default radio button font
//Font Style : Bold And Italic
//Font Size : Default radio button font size
Font newRadioButtonFont=new Font(radioButton.getFont().getName(),Font.ITALIC+Font.BOLD,radioButton.getFont().getSize());

//Set JRadioButton font using new created font
radioButton.setFont(newRadioButtonFont);

//Create a window using JFrame with title ( Set JRadioButton text bold and italic )
JFrame frame=new JFrame("Set JRadioButton text bold and italic");

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created radio button into JFrame
frame.add(radioButton);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JRadioButton text italic

Source code below will show you, how to set JRadioButton text to italic.

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


import javax.swing.JRadioButton;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJRadioButtonTextItalic
{
public static void main(String[]args)
{
//Create radio button using JRadioButton with text ( I am a radio button )
JRadioButton radioButton=new JRadioButton("I am a radio button");

//Create font.
//Font Name : Default radio button font
//Font Style : Italic
//Font Size : Default radio button font size
Font newRadioButtonFont=new Font(radioButton.getFont().getName(),Font.ITALIC,radioButton.getFont().getSize());

//Set JRadioButton font using new created font
radioButton.setFont(newRadioButtonFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created radio button into JFrame
frame.add(radioButton);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JRadioButton text bold

Source code below will show you, how to set JRadioButton text to bold.

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


import javax.swing.JRadioButton;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJRadioButtonTextBold
{
public static void main(String[]args)
{
//Create radio button using JRadioButton with text ( I am a radio button )
JRadioButton radioButton=new JRadioButton("I am a radio button");

//Create font.
//Font Name : Default radio button font
//Font Style : Bold
//Font Size : Default radio button font size
Font newRadioButtonFont=new Font(radioButton.getFont().getName(),Font.BOLD,radioButton.getFont().getSize());

//Set JRadioButton font using new created font
radioButton.setFont(newRadioButtonFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created radio button into JFrame
frame.add(radioButton);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JRadioButton text size

Source code below will show you, how to set JRadioButton text size.

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


import javax.swing.JRadioButton;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJRadioButtonTextSize
{
public static void main(String[]args)
{
//Create radio button using JRadioButton with text ( I am a radio button )
JRadioButton radioButton=new JRadioButton("I am a radio button");

//Create font.
//Font Name : Default radio button font
//Font Style : Default radio button font style
//Font Size : 22
Font newRadioButtonFont=new Font(radioButton.getFont().getName(),radioButton.getFont().getStyle(),22);

//Set JRadioButton font using new created font
radioButton.setFont(newRadioButtonFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created radio button into JFrame
frame.add(radioButton);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JRadioButton text font

Source code below will show you, how to set JRadioButton text font.

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


import javax.swing.JRadioButton;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJRadioButtonTextFont
{
public static void main(String[]args)
{
//Create radio button using JRadioButton with text ( I am a radio button )
JRadioButton radioButton=new JRadioButton("I am a radio button");

//Create font.
//Font Name : Tahoma
//Font Style : Default radio button font style
//Font Size : Default radio button font size
Font newRadioButtonFont=new Font("Tahoma",radioButton.getFont().getStyle(),radioButton.getFont().getSize());

//Set JRadioButton font using new created font
radioButton.setFont(newRadioButtonFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created radio button into JFrame
frame.add(radioButton);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JCheckBox text bold and italic

Source code below will show you, how to set JCheckBox text to bold and italic.

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


import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJCheckBoxTextBoldAndItalic
{
public static void main(String[]args)
{
//Create check box using JCheckBox with text ( I am a check box )
JCheckBox checkBox=new JCheckBox("I am a check box");

//Create font.
//Font Name : Default check box font
//Font Style : Bold And Italic
//Font Size : Default check box font size
Font newCheckBoxFont=new Font(checkBox.getFont().getName(),Font.ITALIC+Font.BOLD,checkBox.getFont().getSize());

//Set JCheckBox font using new created font
checkBox.setFont(newCheckBoxFont);

//Create a window using JFrame with title ( Set JCheckBox text bold and italic )
JFrame frame=new JFrame("Set JCheckBox text bold and italic");

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created check box into JFrame
frame.add(checkBox);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JCheckBox text italic

Source code below will show you, how to set JCheckBox text to italic.

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


import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJCheckBoxTextItalic
{
public static void main(String[]args)
{
//Create check box using JCheckBox with text ( I am a check box )
JCheckBox checkBox=new JCheckBox("I am a check box");

//Create font.
//Font Name : Default check box font
//Font Style : Italic
//Font Size : Default check box font size
Font newCheckBoxFont=new Font(checkBox.getFont().getName(),Font.ITALIC,checkBox.getFont().getSize());

//Set JCheckBox font using new created font
checkBox.setFont(newCheckBoxFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created check box into JFrame
frame.add(checkBox);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JCheckBox text bold

Source code below will show you, how to set JCheckBox text to bold.

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


import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJCheckBoxTextBold
{
public static void main(String[]args)
{
//Create check box using JCheckBox with text ( I am a check box )
JCheckBox checkBox=new JCheckBox("I am a check box");

//Create font.
//Font Name : Default check box font
//Font Style : Bold
//Font Size : Default check box font size
Font newCheckBoxFont=new Font(checkBox.getFont().getName(),Font.BOLD,checkBox.getFont().getSize());

//Set JCheckBox font using new created font
checkBox.setFont(newCheckBoxFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created check box into JFrame
frame.add(checkBox);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JCheckBox text size

Source code below will show you, how to set JCheckBox text size.

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


import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJCheckBoxTextSize
{
public static void main(String[]args)
{
//Create check box using JCheckBox with text ( I am a check box )
JCheckBox checkBox=new JCheckBox("I am a check box");

//Create font.
//Font Name : Default check box font
//Font Style : Default check box font style
//Font Size : 22
Font newCheckBoxFont=new Font(checkBox.getFont().getName(),checkBox.getFont().getStyle(),22);

//Set JCheckBox font using new created font
checkBox.setFont(newCheckBoxFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created check box into JFrame
frame.add(checkBox);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JCheckBox text font

Source code below will show you, how to set JCheckBox text font.

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


import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJCheckBoxTextFont
{
public static void main(String[]args)
{
//Create check box using JCheckBox with text ( I am a check box )
JCheckBox checkBox=new JCheckBox("I am a check box");

//Create font.
//Font Name : Tahoma
//Font Style : Default check box font style
//Font Size : Default check box font size
Font newCheckBoxFont=new Font("Tahoma",checkBox.getFont().getStyle(),checkBox.getFont().getSize());

//Set JCheckBox font using new created font
checkBox.setFont(newCheckBoxFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created check box into JFrame
frame.add(checkBox);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JLabel text bold and italic

Source code below will show you, how to set JLabel text to bold and italic.

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


import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJLabelTextBoldAndItalic
{
public static void main(String[]args)
{
//Create label using JLabel with text ( HI EVERYONE !! I love you all )
JLabel label=new JLabel("HI EVERYONE !! I love you all",SwingConstants.CENTER);

//Create font.
//Font Name : Default label font
//Font Style : Bold And Italic
//Font Size : Default label font size
Font newLabelFont=new Font(label.getFont().getName(),Font.ITALIC+Font.BOLD,label.getFont().getSize());

//Set JLabel font using new created font
label.setFont(newLabelFont);

//Create a window using JFrame with title ( Set JLabel text bold and italic )
JFrame frame=new JFrame("Set JLabel text bold and italic");

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created label into JFrame
frame.add(label);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JLabel text italic

Source code below will show you, how to set JLabel text to italic.

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


import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJLabelTextItalic
{
public static void main(String[]args)
{
//Create label using JLabel with text ( HI EVERYONE !! I love you all )
JLabel label=new JLabel("HI EVERYONE !! I love you all",SwingConstants.CENTER);

//Create font.
//Font Name : Default label font
//Font Style : Italic
//Font Size : Default label font size
Font newLabelFont=new Font(label.getFont().getName(),Font.ITALIC,label.getFont().getSize());

//Set JLabel font using new created font
label.setFont(newLabelFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created label into JFrame
frame.add(label);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JLabel text bold

Source code below will show you, how to set JLabel text to bold.

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


import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJLabelTextBold
{
public static void main(String[]args)
{
//Create label using JLabel with text ( HI EVERYONE !! I love you all )
JLabel label=new JLabel("HI EVERYONE !! I love you all",SwingConstants.CENTER);

//Create font.
//Font Name : Default label font
//Font Style : Bold
//Font Size : Default label font size
Font newLabelFont=new Font(label.getFont().getName(),Font.BOLD,label.getFont().getSize());

//Set JLabel font using new created font
label.setFont(newLabelFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created label into JFrame
frame.add(label);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JLabel text size

Source code below will show you, how to set JLabel text size.

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


import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJLabelTextSize
{
public static void main(String[]args)
{
//Create label using JLabel with text ( HI EVERYONE !! I love you all )
JLabel label=new JLabel("HI EVERYONE !! I love you all",SwingConstants.CENTER);

//Create font.
//Font Name : Default label font
//Font Style : Default label font style
//Font Size : 22
Font newLabelFont=new Font(label.getFont().getName(),label.getFont().getStyle(),22);

//Set JLabel font using new created font
label.setFont(newLabelFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created label into JFrame
frame.add(label);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JLabel text font

Source code below will show you, how to set JLabel text font.

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


import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.SwingConstants;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJLabelTextFont
{
public static void main(String[]args)
{
//Create label using JLabel with text ( HI EVERYONE !! I love you all )
JLabel label=new JLabel("HI EVERYONE !! I love you all",SwingConstants.CENTER);

//Create font.
//Font Name : Tahoma
//Font Style : Default label font style
//Font Size : Default label font size
Font newLabelFont=new Font("Tahoma",label.getFont().getStyle(),label.getFont().getSize());

//Set JLabel font using new created font
label.setFont(newLabelFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created label into JFrame
frame.add(label);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,200);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JTextArea text bold and italic

Source code below will show you, how to set JTextArea text to bold and italic.

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


import javax.swing.JTextArea;
import javax.swing.JFrame;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJTextAreaTextBoldAndItalic
{
public static void main(String[]args)
{
//Create text area using JTextArea
JTextArea textArea=new JTextArea();

//Set line wrap to true
textArea.setLineWrap(true);

//Create font.
//Font Name : Default text area font
//Font Style : Bold And Italic
//Font Size : Default text area font size
Font newTextAreaFont=new Font(textArea.getFont().getName(),Font.ITALIC+Font.BOLD,textArea.getFont().getSize());

//Set JTextArea font using new created font
textArea.setFont(newTextAreaFont);

//Create a window using JFrame with title ( Set JTextArea text bold and italic )
JFrame frame=new JFrame("Set JTextArea text bold and italic");

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created text area into JFrame
frame.add(textArea);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,500);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JTextArea text italic

Source code below will show you, how to set JTextArea text to italic.

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


import javax.swing.JTextArea;
import javax.swing.JFrame;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJTextAreaTextItalic
{
public static void main(String[]args)
{
//Create text area using JTextArea
JTextArea textArea=new JTextArea();

//Set line wrap to true
textArea.setLineWrap(true);

//Create font.
//Font Name : Default text area font
//Font Style : Italic
//Font Size : Default text area font size
Font newTextAreaFont=new Font(textArea.getFont().getName(),Font.ITALIC,textArea.getFont().getSize());

//Set JTextArea font using new created font
textArea.setFont(newTextAreaFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created text area into JFrame
frame.add(textArea);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,500);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JTextArea text bold

Source code below will show you, how to set JTextArea text to bold.

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


import javax.swing.JTextArea;
import javax.swing.JFrame;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJTextAreaTextBold
{
public static void main(String[]args)
{
//Create text area using JTextArea
JTextArea textArea=new JTextArea();

//Set line wrap to true
textArea.setLineWrap(true);

//Create font.
//Font Name : Default text area font
//Font Style : Bold
//Font Size : Default text area font size
Font newTextAreaFont=new Font(textArea.getFont().getName(),Font.BOLD,textArea.getFont().getSize());

//Set JTextArea font using new created font
textArea.setFont(newTextAreaFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created text area into JFrame
frame.add(textArea);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,500);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JTextArea text size

Source code below will show you, how to set JTextArea text size.

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


import javax.swing.JTextArea;
import javax.swing.JFrame;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJTextAreaTextSize
{
public static void main(String[]args)
{
//Create text area using JTextArea
JTextArea textArea=new JTextArea();

//Set line wrap to true
textArea.setLineWrap(true);

//Create font.
//Font Name : Default text area font
//Font Style : Default text area font style
//Font Size : 22
Font newTextAreaFont=new Font(textArea.getFont().getName(),textArea.getFont().getStyle(),22);

//Set JTextArea font using new created font
textArea.setFont(newTextAreaFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created text area into JFrame
frame.add(textArea);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,500);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JTextArea text font

Source code below will show you, how to set JTextArea text font.

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


import javax.swing.JTextArea;
import javax.swing.JFrame;

import java.awt.BorderLayout;
import java.awt.Font;

public class SetJTextAreaTextFont
{
public static void main(String[]args)
{
//Create text area using JTextArea
JTextArea textArea=new JTextArea();

//Set line wrap to true
textArea.setLineWrap(true);

//Create font.
//Font Name : Tahoma
//Font Style : Default text area font style
//Font Size : Default text area font size
Font newTextAreaFont=new Font("Tahoma",textArea.getFont().getStyle(),textArea.getFont().getSize());

//Set JTextArea font using new created font
textArea.setFont(newTextAreaFont);

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

//Set JFrame layout to BorderLayout
frame.setLayout(new BorderLayout());

//Add created text area into JFrame
frame.add(textArea);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,500);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JButton text bold and italic

Source code below will show you, how to set JButton text to bold and italic.

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


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

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

public class SetJButtonTextBoldAndItalic
{
public static void main(String[]args)
{
//Create button with text ( MY BUTTON )
JButton button=new JButton("MY BUTTON");

//Create font.
//Font Name : Default button font
//Font Style : Bold And Italic
//Font Size : Default button font size
Font newButtonFont=new Font(button.getFont().getName(),Font.ITALIC+Font.BOLD,button.getFont().getSize());

//Set JButton font using new created font
button.setFont(newButtonFont);

//Create a window using JFrame with title ( Set JButton text bold and italic )
JFrame frame=new JFrame("Set JButton text bold and italic");

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created button into JFrame
frame.add(button);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,100);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JTextField text bold and italic

Source code below will show you, how to set JTextField text to bold and italic.

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


import javax.swing.JTextField;
import javax.swing.JFrame;

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

public class SetJTextFieldTextBoldAndItalic
{
public static void main(String[]args)
{
//Create text field using JTextField
JTextField textField=new JTextField(20);

//Create font.
//Font Name : Default text field font
//Font Style : Bold And Italic
//Font Size : Default text field font size
Font newTextFieldFont=new Font(textField.getFont().getName(),Font.ITALIC+Font.BOLD,textField.getFont().getSize());

//Set JTextField font using new created font
textField.setFont(newTextFieldFont);

//Create a window using JFrame with title ( Set JTextField text bold and italic )
JFrame frame=new JFrame("Set JTextField text bold and italic");

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created text field into JFrame
frame.add(textField);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,100);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JTextField text italic

Source code below will show you, how to set JTextField text to italic.

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


import javax.swing.JTextField;
import javax.swing.JFrame;

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

public class SetJTextFieldTextItalic
{
public static void main(String[]args)
{
//Create text field using JTextField
JTextField textField=new JTextField(20);

//Create font.
//Font Name : Default text field font
//Font Style : Italic
//Font Size : Default text field font size
Font newTextFieldFont=new Font(textField.getFont().getName(),Font.ITALIC,textField.getFont().getSize());

//Set JTextField font using new created font
textField.setFont(newTextFieldFont);

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

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created text field into JFrame
frame.add(textField);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,100);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JTextField text bold

Source code below will show you, how to set JTextField text to bold.

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


import javax.swing.JTextField;
import javax.swing.JFrame;

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

public class SetJTextFieldTextBold
{
public static void main(String[]args)
{
//Create text field using JTextField
JTextField textField=new JTextField(20);

//Create font.
//Font Name : Default text field font
//Font Style : Bold
//Font Size : Default text field font size
Font newTextFieldFont=new Font(textField.getFont().getName(),Font.BOLD,textField.getFont().getSize());

//Set JTextField font using new created font
textField.setFont(newTextFieldFont);

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

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created text field into JFrame
frame.add(textField);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,100);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JTextField text size

Source code below will show you, how to set JTextField text size.

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


import javax.swing.JTextField;
import javax.swing.JFrame;

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

public class SetJTextFieldTextSize
{
public static void main(String[]args)
{
//Create text field using JTextField
JTextField textField=new JTextField(20);

//Create font.
//Font Name : Default text field font
//Font Style : Default text field font style
//Font Size : 16
Font newTextFieldFont=new Font(textField.getFont().getName(),textField.getFont().getStyle(),16);

//Set JTextField font using new created font
textField.setFont(newTextFieldFont);

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

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created text field into JFrame
frame.add(textField);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,100);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JTextField text font

Source code below will show you, how to set JTextField text font.

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


import javax.swing.JTextField;
import javax.swing.JFrame;

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

public class SetJTextFieldTextFont
{
public static void main(String[]args)
{
//Create text field using JTextField
JTextField textField=new JTextField(20);

//Create font.
//Font Name : Tahoma
//Font Style : Default text field font style
//Font Size : Default text field font size
Font newTextFieldFont=new Font("Tahoma",textField.getFont().getStyle(),textField.getFont().getSize());

//Set JTextField font using new created font
textField.setFont(newTextFieldFont);

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

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created text field into JFrame
frame.add(textField);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,100);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JButton text italic

Source code below will show you, how to set JButton text to italic.

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


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

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

public class SetJButtonTextItalic
{
public static void main(String[]args)
{
//Create button with text ( MY BUTTON )
JButton button=new JButton("MY BUTTON");

//Create font.
//Font Name : Default button font
//Font Style : Italic
//Font Size : Default button font size
Font newButtonFont=new Font(button.getFont().getName(),Font.ITALIC,button.getFont().getSize());

//Set JButton font using new created font
button.setFont(newButtonFont);

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

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created button into JFrame
frame.add(button);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,100);

//Make JFrame visible
frame.setVisible(true);
}
}


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

Set JButton text bold

Source code below will show you, how to set JButton text to bold.

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


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

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

public class SetJButtonTextBold
{
public static void main(String[]args)
{
//Create button with text ( MY BUTTON )
JButton button=new JButton("MY BUTTON");

//Create font.
//Font Name : Default button font
//Font Style : Bold
//Font Size : Default button font size
Font newButtonFont=new Font(button.getFont().getName(),Font.BOLD,button.getFont().getSize());

//Set JButton font using new created font
button.setFont(newButtonFont);

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

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created button into JFrame
frame.add(button);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,100);

//Make JFrame visible
frame.setVisible(true);
}
}


******************************************************************
JUST COMPILE AND EXECUTE IT
******************************************************************
Related Posts Plugin for WordPress, Blogger...

I Also Can Create T-Shirt Logo For You