Tip for BorderLayout

BorderLayout is also a layout manager like FlowLayout. But, it not arrange components in container from left to right like FlowLayout do. It will arrange component in five part.


NORTH
SOUTH
CENTER
EAST
WEST

Example source code for BorderLayout

Tip for FlowLayout

FlowLayout is use to arrange components in a container from left to right. If it reached at the end of the container, but there are still left other component, it will go to the next line in the container and start again arrange component from left to right.

Example of container : JFrame, JPanel, JWindow, JInternalFrame
(Use to hold other component)

Example of component : JPanel, JButton, JTextField, JCheckBox, JRadioButton

Example source code for FlowLayout

Set JTextField background image

Complete source code below will show you, how to set image background in a JTextField. You can download image (textFieldBackgroundImage.jpg) that use in source code at below.

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


import javax.swing.*;

import java.awt.*;

public class SetJTextFieldBackgroundImage extends JTextField
{
public SetJTextFieldBackgroundImage()
{
JFrame frame=new JFrame("Set JTextField background image");
frame.add(this);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,65);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setVisible(true);
}

public void paint(Graphics g)
{
setOpaque(false);

//Image that will be set as JTextField background
//I suggest, image that will be use is blur...
//If image is locate at other location, you must put it's full location address.
//For example : C:\\Documents and Settings\\evergreen\\Desktop\\textFieldBackgroundImage.jpg
ImageIcon ii=new ImageIcon("textFieldBackgroundImage.jpg");
Image i=ii.getImage();
g.drawImage(i,0,0,this);
super.paint(g);
}

public static void main(String[]args)
{
SetJTextFieldBackgroundImage sjtfbi=new SetJTextFieldBackgroundImage();
}
}


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



textFieldBackgroundImage.jpg

Set JButton background color on click

Click here

Determine character is whitespace

Complete source code below will show you, how to determine character is whitespace or not in java.

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


public class DetermineCharacterIsSpace
{
public static void main(String[]args)
{
//Create a space character using char by press spacebar once between single quote(' ')
//You can try change it's value by change it to a letter 'A' for example.
char a=' ';

//Determine created character is space or not
//using method isWhitespace from class Character.
//isWhitespace is a static method, so we don't need to create object when
//we want to use it.
if(Character.isWhitespace(a))
{
//Print (It is a whitespace) if character is a whitespace
System.out.println("It is a whitespace");
}
else
{
//Print (It is not a whitespace) if character is not a whitespace
System.out.println("It is not a whitespace");
}
}
}


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

Determine character is uppercase

Complete source code below will show you, how to determine character is uppercase or not in java.

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


public class DetermineCharacterIsUppercase
{
public static void main(String[]args)
{
//Create a uppercase character using char with value(B)
//You can try change it's value to letter(b)
char a='B';

//Determine created character is uppercase or not
//using method isUpperCase from class Character.
//isUpperCase is a static method, so we don't need to create object when
//we want to use it.
if(Character.isUpperCase(a))
{
//Print (It is an uppercase) if character is an uppercase
System.out.println("It is an uppercase");
}
else
{
//Print (It is not an uppercase) if character is not an uppercase
System.out.println("It is not an uppercase");
}
}
}


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

Determine character is lowercase

Complete source code below will show you, how to determine character is lowercase or not in java.

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


public class DetermineCharacterIsLowercase
{
public static void main(String[]args)
{
//Create a lowercase character using char with value(b)
//You can try change it's value to letter(B)
char a='b';

//Determine created character is lowercase or not
//using method isLowerCase from class Character.
//isLowerCase is a static method, so we don't need to create object when
//we want to use it.
if(Character.isLowerCase(a))
{
//Print (It is a lowercase) if character is a lowercase
System.out.println("It is a lowercase");
}
else
{
//Print (It is not a lowercase) if character is not a lowercase
System.out.println("It is not a lowercase");
}
}
}


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

Determine character is letter or digit

Complete source code below will show you, how to determine character is letter or digit in java.

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


public class DetermineCharacterIsLetterOrDigit
{
public static void main(String[]args)
{
//Create a character using char with value(3)
//You can try change it's value to letter(k)
char a='3';

//Determine created character is letter or digit
//using method isLetterOrDigit from class Character.
//isLetterOrDigit is a static method, so we don't need to create object when
//we want to use it.
if(Character.isLetterOrDigit(a))
{
//Print (It is a letter or a digit) if character is a letter or digit
System.out.println("It is a letter or a digit");
}
else
{
//Print (It is not a letter or digit) if character is not a letter or digit
System.out.println("It is not a letter or digit");
}
}
}


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

Determine character is letter or not

Complete source code below will show you, how to determine character is letter or not in java.

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


public class DetermineCharacterIsLetter
{
public static void main(String[]args)
{
//Create a character using char with value(m)
char a='m';

//Determine created character is letter or not
//using method isLetter from class Character.
//isLetter is a static method, so we don't need to create object when
//we want to use it.
if(Character.isLetter(a))
{
//Print (It is a letter) if character is a letter
System.out.println("It is a letter");
}
else
{
//Print (It is not a letter) if character is not a letter
System.out.println("It is not a letter");
}
}
}


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

Determine character is digit or not

Complete source code below will show you, how to determine character is digit or not in java.

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


public class DetermineCharacterIsDigit
{
public static void main(String[]args)
{
//Create a character using char with value(4)
char a='4';

//Determine created character is digit or not
//using method isDigit from class Character.
//isDigit is a static method, so we don't need to create object when
//we want to use it.
if(Character.isDigit(a))
{
//Print (It is a digit) if character is a digit
System.out.println("It is a digit");
}
else
{
//Print (It is not a digit) if character is not a digit
System.out.println("It is not a digit");
}
}
}


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

RELAXING NATURE VIDEO