0% found this document useful (0 votes)
25 views6 pages

Args JF JL jl1 jl2 JTF JP JB JF JF JF JF: // Auto-Generated Method Stub

The document contains Java Swing applications for three different functionalities: a password login system, a simple calculator, and an increment/decrement counter. Each application creates a JFrame with various components like labels, text fields, and buttons, and implements action listeners to handle user interactions. The applications demonstrate basic GUI programming and event handling in Java.

Uploaded by

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

Args JF JL jl1 jl2 JTF JP JB JF JF JF JF: // Auto-Generated Method Stub

The document contains Java Swing applications for three different functionalities: a password login system, a simple calculator, and an increment/decrement counter. Each application creates a JFrame with various components like labels, text fields, and buttons, and implements action listeners to handle user interactions. The applications demonstrate basic GUI programming and event handling in Java.

Uploaded by

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

package swings;

import java.awt.event.*;
import javax.swing.*;
public class Password {

public static void main(String[] args) {


// TODO Auto-generated method stub
JFrame jf;
JLabel jl;
JLabel jl1;
JLabel jl2;
JTextField jtf;
JPasswordField jp;
JButton jb;
jf=new JFrame("Displaymessage");
jf.setLayout(null);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setSize(500,500);

jl1=new JLabel("Username :");


jl1.setBounds(60,60, 125,20);
jf.add(jl1);

jtf=new JTextField("");
jtf.setBounds(150, 60, 125, 20);
jf.add(jtf);

jl2=new JLabel("Password :");


jl2.setBounds(60,90, 125, 20);
jf.add(jl2);

jp=new JPasswordField("");
jp.setBounds(150,90, 125,20);
jf.add(jp);

jb= new JButton("Login");


jb.setBounds(150, 120, 90, 20);
jf.add(jb);

jl=new JLabel();
jb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String name = jtf.getText();
String username= jtf.getText();
@SuppressWarnings("deprecation")
String password = jp.getText();
if(name.equalsIgnoreCase(username)&&name.equals(password))
{
jl.setText("Login Successfull");
}
else
jl.setText("Login failed");
}
});

jl.setBounds(175,135,120,20);
jf.add(jl);
jf.setVisible(true);

}
}
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Calculate {
public static void main(String[] args) {
// TODO Auto-generated method stub
JFrame jf;
JLabel jl;
JLabel jl1;
JLabel jl2;
JTextField jtf,jtf1,jtf2;
JButton jb;
jf=new JFrame("CALCULATE");
jf.setLayout(null);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setSize(500,250);

jl1=new JLabel("Enter a :");


jl1.setBounds(50,50, 125, 20);
jf.add(jl1);

jtf=new JTextField("");
jtf.setBounds(120, 50, 125, 20);
jf.add(jtf);

jl2=new JLabel("Enter b :");


jl2.setBounds(50,70, 125, 20);
jf.add(jl2);

jtf1=new JTextField("");
jtf1.setBounds(120, 80, 125,20);
jf.add(jtf1);

jb= new JButton("calculate");


jb.setBounds(150, 120, 90, 20);
jf.add(jb);

jl=new JLabel();

jb.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
int a =Integer.parseInt(jtf.getText());

int b=Integer.parseInt(jtf1.getText());

String a1=String.valueOf(a);
jl.setText(a1);
String b1=String.valueOf(b);

if(a>b)
{
int c=a*b;
String c1= String.valueOf(c);
jl.setText(c1);
}
else
{
int d=b%a;
String d1=String.valueOf(d);
jl.setText(d1);
}
}
});

jl.setBounds(175,155,120,20);
jf.add(jl);
jf.setVisible(true);
}
}
import javax.swing.*;
import java.awt.event.*;
public class Increment {

public static void main(String[] args) {


// TODO Auto-generated method stub
JFrame jf;
JLabel jl;
JTextField jtf;
JButton jb1,jb2;
jf=new JFrame("O - 50");
jf.setLayout(null);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setSize(500,500);
jb1=new JButton(" + ");
jb1.setBounds(150, 70, 50, 20);
jf.add(jb1);
jtf=new JTextField("0");
jtf.setBounds(120, 100, 125,20);
jf.add(jtf);
jb2=new JButton(" - ");
jb2.setBounds(150, 130, 50,20);
jf.add(jb2);
jl=new JLabel();
//String p=jtf.getText();
jb1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent
e)
{
String a=jtf.getText();
int a1=Integer.parseInt(a);
if(a1<50)
{
a1++;
String a2= String.valueOf(a1);
jtf.setText(a2);
}
else
{
jl.setText("Limit Reached");
}

}
});
jb2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String b= jtf.getText();
int b1=Integer.parseInt(b);
if(b1>0)
{
b1--;
String b2= String.valueOf(b1);
jtf.setText(b2);
}
else
{
jl.setText("Limit Reached");
}

}
});

jl.setBounds(175,155,180,20);
jf.add(jl);
jf.setVisible(true);
}

You might also like