.jpg)
Example source code for GridLayout
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();
}
}
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");
}
}
}