0% found this document useful (0 votes)
4 views

PROGRAM7

The document provides a Java program that creates a user profile form using Swing components. It includes three text fields for name, age, and qualification, as well as a multi-line text area for the address. Upon clicking the submit button, it displays the entered information in a dialog box.

Uploaded by

joyalprincess
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)
4 views

PROGRAM7

The document provides a Java program that creates a user profile form using Swing components. It includes three text fields for name, age, and qualification, as well as a multi-line text area for the address. Upon clicking the submit button, it displays the entered information in a dialog box.

Uploaded by

joyalprincess
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

PROGRAM-7

WRITE A JAVA PROGRAM TO CREATE A FRAME WITH THREE TEXT FIELDS FOR
NAME AGE AND QUALIFICATION AND A TEXT FIELD FOR MULTIPLE LINE FOR
ADDRESS
SOURCE CODE
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class jframe implements ActionListener
{
JFrame jf;
JButton submit;
JLabel nameLabel,ageLabel,qualificationLabel,addressLabel;
JTextField name,age,qualification;
JTextArea address;
public jframe()
{ jf=new JFrame("User Profile Form");
jf.setLayout(new GridLayout(5,2,3,3));;
// Create labels and text fields
nameLabel = new JLabel("Name:");
name = new JTextField(20);
ageLabel = new JLabel("Age:");
age = new JTextField(20);
qualificationLabel = new JLabel("Qualification:");
qualification = new JTextField(20);
addressLabel = new JLabel("Address:");
address = new JTextArea(5, 20);
submit = new JButton("Submit");
submit.addActionListener(this);
jf.add(nameLabel);
jf.add(name);
jf.add(ageLabel);
jf.add(age);
jf.add(qualificationLabel);
jf.add(qualification);
jf.add(addressLabel);
jf.add(new JScrollPane(address));
jf.add(submit);
jf.setVisible(true);
jf.setSize(700,600);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("Submit"))
{
// Display all values in a dialog box
String message = "Name: " + name.getText() + "\nAge: " + age.getText() + "\nQualification: "
+ qualification.getText() + "\nAddress:\n" + address.getText();
JOptionPane.showMessageDialog(jf, message);
}
}
}
class PL7
{
public static void main(String args[])
{
jframe j=new jframe();
}
}
PROGRAM-7 – OUTPUT

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy