package org.best.example;
/*
Set JTextField Border Example
This java example shows how to create a border for JTextField using
Java Swing JTextField class.
*/
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.BorderFactory;
import javax.swing.JApplet;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.border.Border;
/*
<applet code="JTextFieldSetBorderExample" width=200 height=200>
</applet>
*/
public class JTextFieldSetBorderExample extends JApplet{
public void init(){
//set flow layout for the applet
this.getContentPane().setLayout(new FlowLayout());
//create new JTextField
JTextField field = new JTextField("JTextField Border Example",20);
/*
* Create new custom border for JTextField
*/
Border border = BorderFactory.createLineBorder(Color.red);
/*
* To set JTextField's border use,
* void setBorder(Border b)
* method.
*/
field.setBorder(border);
add(field);
}
}
/*
Set JTextField Border Example
This java example shows how to create a border for JTextField using
Java Swing JTextField class.
*/
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.BorderFactory;
import javax.swing.JApplet;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.border.Border;
/*
<applet code="JTextFieldSetBorderExample" width=200 height=200>
</applet>
*/
public class JTextFieldSetBorderExample extends JApplet{
public void init(){
//set flow layout for the applet
this.getContentPane().setLayout(new FlowLayout());
//create new JTextField
JTextField field = new JTextField("JTextField Border Example",20);
/*
* Create new custom border for JTextField
*/
Border border = BorderFactory.createLineBorder(Color.red);
/*
* To set JTextField's border use,
* void setBorder(Border b)
* method.
*/
field.setBorder(border);
add(field);
}
}
No comments:
Post a Comment