0% found this document useful (0 votes)
24 views1 page

JFrame

This Java code creates a simple GUI application with labels and text fields to collect a user's name, age, address, username, and password. It initializes a JFrame window with a FlowLayout, adds the label and text field components, sets the window size and location, and makes it visible to the user.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

JFrame

This Java code creates a simple GUI application with labels and text fields to collect a user's name, age, address, username, and password. It initializes a JFrame window with a FlowLayout, adds the label and text field components, sets the window size and location, and makes it visible to the user.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import javax.swing.

*;
import javax.swing.JLabel;
import java.awt.FlowLayout;

public class Main {

public static void main(String[] args) {

JFrame frm1 = new JFrame ("Main Form");


JLabel lblNAME = new JLabel ("Name:", JLabel.CENTER);
JTextField txtName = new JTextField(15);
JLabel lblAge = new JLabel ("Age:", JLabel. CENTER);
JTextField txtAge = new JTextField(15);
JLabel lblAddress = new JLabel ("Address:", JLabel. CENTER);
JTextField txtAddress = new JTextField(15);
JLabel lblUserName = new JLabel ("UserName:", JLabel. CENTER);
JTextField txtUserName = new JTextField(15);
JLabel lblPassword = new JLabel ("Password:", JLabel. CENTER);
JTextField txtPassword = new JTextField(15);
JButton btnSave = new JButton ("Save");

frm1.setLayout(new FlowLayout());

frm1.add(lblNAME);
frm1.add(txtName);
frm1.add(lblAge);
frm1.add(txtAge);
frm1.add(lblAddress);
frm1.add(txtAddress);
frm1.add(lblUserName);
frm1.add(txtUserName);
frm1.add(lblPassword);
frm1.add(txtPassword);
frm1.add(btnSave);
frm1.setSize(250, 350);
frm1.setVisible(true);
frm1.setLocation(100, 100);
frm1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm1.setResizable(false);
}

You might also like