Set JRadioButton text color

Source code below will show you, how to set JRadioButton text color base on RGB. You can get RGB value for your color using "Color picker" at above.

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


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

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

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

//Create JFrame with title ( Set JRadioButton text color )
JFrame frame=new JFrame("Set JRadioButton text color");

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

//Set color base on RGB
//You can get RGB value for your color at "Color picker" at above
//R=255
//G=0
//B=0
Color color=new Color(255,0,0);

//Set JRadioButton text color to color that you choose
radioButton.setForeground(color);

//Add JRadioButton into JFrame
frame.add(radioButton);

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

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

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


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

Set JRadioButton background color

Source code below will show you, how to set JRadioButton background color base on RGB. You can get RGB value for your color using "Color picker" at above.

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


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

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

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

//Create JFrame with title ( Set JRadioButton background color )
JFrame frame=new JFrame("Set JRadioButton background color");

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

//Set color base on RGB
//You can get RGB value for your color at "Color picker" at above
//R=255
//G=0
//B=0
Color color=new Color(255,0,0);

//Set JRadioButton background color to color that you choose
radioButton.setBackground(color);

//Add JRadioButton into JFrame
frame.add(radioButton);

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

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

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


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

Set JComboBox text color

Source code below will show you, how to set JComboBox text color base on RGB. You can get RGB value for your color using "Color picker" at above.

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


import javax.swing.JComboBox;
import javax.swing.JFrame;

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

public class SetJComboBoxTextColor
{
public static void main(String[]args)
{
//Create JComboBox contents
String[]comboBoxContents={"Cow","Sheep","Horse"};

//Create comboBox using JComboBox
JComboBox comboBox=new JComboBox(comboBoxContents);

//Create JFrame with title ( Set JComboBox text color )
JFrame frame=new JFrame("Set JComboBox text color");

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

//Set color base on RGB
//You can get RGB value for your color at "Color picker" at above
//R=255
//G=0
//B=0
Color color=new Color(255,0,0);

//Set JComboBox text color to color that you choose
comboBox.setForeground(color);

//Add JComboBox into JFrame
frame.add(comboBox);

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

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

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


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

Set JComboBox background color

Source code below will show you, how to set JComboBox background color base on RGB. You can get RGB value for your color using "Color picker" at above.

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


import javax.swing.JComboBox;
import javax.swing.JFrame;

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

public class SetJComboBoxBackgroundColor
{
public static void main(String[]args)
{
//Create JComboBox contents
String[]comboBoxContents={"Cow","Sheep","Horse"};

//Create comboBox using JComboBox
JComboBox comboBox=new JComboBox(comboBoxContents);

//Create JFrame with title ( Set JComboBox background color )
JFrame frame=new JFrame("Set JComboBox background color");

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

//Set color base on RGB
//You can get RGB value for your color at "Color picker" at above
//R=255
//G=0
//B=0
Color color=new Color(255,0,0);

//Set JComboBox background color to color that you choose
comboBox.setBackground(color);

//Add JComboBox into JFrame
frame.add(comboBox);

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

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

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


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

Set JList text color

Source code below will show you, how to set JList text color base on RGB. You can get RGB value for your color using "Color picker" at above.

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


import javax.swing.JList;
import javax.swing.JFrame;

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

public class SetJListTextColor
{
public static void main(String[]args)
{
//Create JList contents
String[]listContents={"Cow","Sheep","Horse"};

//Create list using JList
JList list=new JList(listContents);

//Create JFrame with title ( Set JList text color )
JFrame frame=new JFrame("Set JList text color");

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

//Set color base on RGB
//You can get RGB value for your color at "Color picker" at above
//R=255
//G=0
//B=0
Color color=new Color(255,0,0);

//Set JList text color to color that you choose
list.setForeground(color);

//Add JList into JFrame
frame.add(list);

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

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

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


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

Set JList background color

Source code below will show you, how to set JList background color base on RGB. You can get RGB value for your color using "Color picker" at above.

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


import javax.swing.JList;
import javax.swing.JFrame;

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

public class SetJListBackgroundColor
{
public static void main(String[]args)
{
//Create JList contents
String[]listContents={"Cow","Sheep","Horse"};

//Create list using JList
JList list=new JList(listContents);

//Create JFrame with title ( Set JList background color )
JFrame frame=new JFrame("Set JList background color");

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

//Set color base on RGB
//You can get RGB value for your color at "Color picker" at above
//R=255
//G=0
//B=0
Color color=new Color(255,0,0);

//Set JList background color to color that you choose
list.setBackground(color);

//Add JList into JFrame
frame.add(list);

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

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

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


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

Set password symbol or echo character color for JPasswordField

Source code below will show you, how to set JPasswordField echo character color base on RGB. You can get RGB value for your color using "Color picker" at above.

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


import javax.swing.JPasswordField;
import javax.swing.JFrame;

import java.awt.Color;

public class SetJPasswordFieldEchoCharacterColor
{
public static void main(String[]args)
{
//Create password field with number of columns equal to 10
JPasswordField passwordField=new JPasswordField(10);

//Create JFrame with title ( Set JPasswordField echo character color )
JFrame frame=new JFrame("Set JPasswordField echo character color");

//Set color base on RGB
//You can get RGB value for your color at "Color picker" at above
//R=255
//G=0
//B=0
Color color=new Color(255,0,0);

//Set JPasswordField echo character color to color that you choose
passwordField.setForeground(color);

//Add JPasswordField into JFrame
frame.add(passwordField);

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

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

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


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

Set JPasswordField background color

Source code below will show you, how to set JPasswordField background color base on RGB. You can get RGB value for your color using "Color picker" at above.

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


import javax.swing.JPasswordField;
import javax.swing.JFrame;

import java.awt.Color;

public class SetJPasswordFieldBackgroundColor
{
public static void main(String[]args)
{
//Create password field with number of columns equal to 10
JPasswordField passwordField=new JPasswordField(10);

//Create JFrame with title ( Set JPasswordField background color )
JFrame frame=new JFrame("Set JPasswordField background color");

//Set color base on RGB
//You can get RGB value for your color at "Color picker" at above
//R=255
//G=0
//B=0
Color color=new Color(255,0,0);

//Set JPasswordField background color to color that you choose
passwordField.setBackground(color);

//Add JPasswordField into JFrame
frame.add(passwordField);

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

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

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


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

Get password length from JPasswordField

Source code below will show you, how to get password length from a JPasswordField.

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


import javax.swing.JPasswordField;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import java.awt.GridLayout;

public class GetPasswordLength implements ActionListener
{
//Create a password field using JPasswordField with number of columns equal to 10
JPasswordField passwordField=new JPasswordField(10);

//Create a window using JFrame with title ( Get password length )
JFrame frame=new JFrame("Get password length");

//Create a button with text ( GET PASSWORD LENGTH )
JButton button=new JButton("GET PASSWORD LENGTH");

public GetPasswordLength()
{
//Add action listener to button
button.addActionListener(this);

//Set JFrame layout using GridLayout
frame.setLayout(new GridLayout(2,1));

//Add password field into JFrame
frame.add(passwordField);

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

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

//Set JFrame size to :
//WIDTH = 400 pixels
//HEIGHT = 120 pixels
frame.setSize(400,120);

//Make JFrame visible. So we can see it
frame.setVisible(true);
}

//Action for button
public void actionPerformed(ActionEvent event)
{
if(event.getSource()==button)
{
//Show message box that contain password length
JOptionPane.showMessageDialog(frame,"PASSWORD LENGTH : "+(passwordField.getText().length()));
}
}

public static void main(String[]args)
{
GetPasswordLength gpl=new GetPasswordLength();
}
}


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

Set password symbol or echo character for JPasswordField

Source code below will show you, how to set symbol that will be use in password field that build using JPasswordField. It also called echo character.

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


import javax.swing.JPasswordField;
import javax.swing.JFrame;

import java.awt.FlowLayout;

public class SetPasswordSymbol
{
public static void main(String[]args)
{
//Create a password field with number of columns equal to 10
JPasswordField passwordField=new JPasswordField(10);

//Set password symbol
//In my case i use *
//You can change for what you want.But make sure it is only one character
//This is because, method setEchoChar receive only one character
passwordField.setEchoChar('*');


//Create a JFrame with title ( Set Password Symbol )
JFrame frame=new JFrame("Set Password Symbol");

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

//Add password field into JFrame
frame.add(passwordField);

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

//Set JFrame size to :
//WIDTH : 300 pixels
//HEIGHT : 65 pixels
frame.setSize(300,65);

//Make JFrame visible. So we can see it
frame.setVisible(true);
}
}


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

RELAXING NATURE VIDEO