0% found this document useful (0 votes)
22 views3 pages

Unit-3 User Interface Components Using Swing

Third unit rdbms

Uploaded by

khanjunaid7796
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

Unit-3 User Interface Components Using Swing

Third unit rdbms

Uploaded by

khanjunaid7796
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Unit-3 User Interface Components Using Swing

Text Field:-The object of a TextField class is a text component that allows the editing of a single line text. It inherits
TextComponent class.
Java AWT TextField Example
import java.awt.*;
class TextFieldExample{
public static void main(String args[]){
Frame f= new Frame("TextField Example");
TextField t1,t2;
t1=new TextField("Welcome to Javatpoint.");
t1.setBounds(50,100, 200,30);
t2=new TextField("AWT Tutorial");
t2.setBounds(50,150, 200,30);
f.add(t1); f.add(t2);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
}
Text Area:-The object of a TextArea class is a multi line region that displays text. It allows the editing of multiple line text. It
inherits TextComponent class.
import java.awt.*;
public class TextAreaExample
{
TextAreaExample(){
Frame f= new Frame();
TextArea area=new TextArea("Welcome to javatpoint");
area.setBounds(10,30, 300,300);
f.add(area);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[])
{
new TextAreaExample();
}
}
Java JPasswordField:-The object of a JPasswordField class is a text component specialized for password entry. It allows
the editing of a single line of text. It inherits JTextField class.

Java JPasswordField Example:-


import javax.swing.*;
public class PasswordFieldExample
{
public static void main(String[] args)
{
JFrame f=new JFrame("Password Field Example");
JPasswordField value = new JPasswordField();
JLabel l1=new JLabel("Password:");
l1.setBounds(20,100, 80,30);
value.setBounds(100,100,100,30);
f.add(value); f.add(l1);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
}

You might also like