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

Assignment 3

The document describes a Java program for a hair salon management system. It includes classes for the login screen, main application window, and bill receipt. The main window allows selecting services, entering customer details, and generating a bill receipt.

Uploaded by

aqsa ismail
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)
26 views

Assignment 3

The document describes a Java program for a hair salon management system. It includes classes for the login screen, main application window, and bill receipt. The main window allows selecting services, entering customer details, and generating a bill receipt.

Uploaded by

aqsa ismail
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/ 14

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package a3;

import java.awt.BorderLayout;

import java.awt.Container;

import java.awt.Font;

import java.awt.GridBagConstraints;

import java.awt.GridBagLayout;

import java.awt.Image;

import java.awt.Insets;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

import javax.swing.BorderFactory;

import javax.swing.ButtonGroup;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JFrame;

import static javax.swing.JFrame.EXIT_ON_CLOSE;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JRadioButton;
import javax.swing.JTextField;

import javax.swing.JToolBar;

import javax.swing.UIManager;

/**

* @author Syed Danish

*/

public class A3 {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

Loginbox l = new Loginbox();

HairSaloon hs = new HairSaloon();

class HairSaloon extends JFrame implements ActionListener

JFrame f;

JToolBar toolbar;

JButton crto, prtbill, lgot, crt,pr1h,sp1, sp2, sp3;

JPanel p,pt,p1,pf,bp;

ImageIcon img1,img2,img3;

JLabel cd,d,cn,ss,sc,check,mcn,dat,scl, pcl, t,bl;

JTextField cnt,sct;

JRadioButton pr1,pr2,pr3;

HairSaloon(){
pt = new JPanel();

bp = new JPanel();

check = new JLabel("");

dat = new JLabel("");

scl = new JLabel("");

pcl = new JLabel("");

t = new JLabel(""); bl =new JLabel("");

p1 = new JPanel();

p1.setLayout(new GridBagLayout());

GridBagConstraints c = new GridBagConstraints();

c.insets = new Insets(10,0,0,0);

pf = new JPanel();

setTitle("Hair Saloon");

f = new JFrame();

f.setLayout(new BorderLayout());

toolbar = new JToolBar();

p = new JPanel();

crto = new JButton(); crto.addActionListener(this);

crto.setBorder(BorderFactory.createEmptyBorder());

img1 = new ImageIcon(new ImageIcon("E:\\img\\createc.png").getImage().getScaledInstance(100,


100, Image.SCALE_DEFAULT));

crto.setIcon(img1);

prtbill = new JButton(); prtbill.addActionListener(this);

prtbill.setBorder(BorderFactory.createEmptyBorder());

img2 = new ImageIcon(new ImageIcon("E:\\img\\bill.png").getImage().getScaledInstance(100, 100,


Image.SCALE_DEFAULT));

prtbill.setIcon(img2);
lgot = new JButton(); lgot.addActionListener(this);

lgot.setBorder(BorderFactory.createEmptyBorder());

img3 = new ImageIcon(new ImageIcon("E:\\img\\logout.png").getImage().getScaledInstance(100,


100, Image.SCALE_DEFAULT));

lgot.setIcon(img3);

p.add(crto); p.add(prtbill); p.add(lgot);

toolbar.add(p);

f.add(toolbar, BorderLayout.NORTH);

cd = new JLabel("Customer Details");

cd.setFont(new Font("Times New Roman", Font.PLAIN, 24));

c.gridx = 1; c.gridy = 0;

c.anchor = GridBagConstraints.LINE_START;

p1.add(cd, c);

DateFormat df = new SimpleDateFormat("dd/MM/yy HH:mm:ss");

Date dateobj = new Date();

d = new JLabel(df.format(dateobj));

c.gridx = 1; c.gridy = 1;

p1.add(d, c);

cn = new JLabel("Customer Name : ");

mcn = new JLabel("");

c.gridx = 0; c.gridy = 2;

p1.add(cn, c);

cnt = new JTextField(15);


c.gridx = 1; c.gridy = 2;

c.anchor = GridBagConstraints.LINE_START;

p1.add(cnt, c);

ss = new JLabel("Select Style : ");

c.gridx = 0; c.gridy = 3;

p1.add(ss, c);

pr1 = new JRadioButton("1000");

sp1 = new JButton();

sp1.setBorder(BorderFactory.createEmptyBorder());

ImageIcon im1 = new ImageIcon((new


ImageIcon("E:\\img\\2.png").getImage().getScaledInstance(30, 30, Image.SCALE_DEFAULT)));

sp1.setIcon(im1);

c.gridx = 0; c.gridy = 0;

pt.add(pr1, c);

c.gridx = 1; c.gridy = 0;

pt.add(sp1, c);

pr1h = new JButton("ch");

pr2 = new JRadioButton("2000");

c.gridx = 2; c.gridy = 0;

pt.add(pr2, c);

sp2 = new JButton();

sp2.setBorder(BorderFactory.createEmptyBorder());

ImageIcon im2 = new ImageIcon((new


ImageIcon("E:\\img\\ex1.png").getImage().getScaledInstance(30, 30, Image.SCALE_DEFAULT)));

sp2.setIcon(im2);
c.gridx = 3; c.gridy = 0;

pt.add(sp2);

pr3 = new JRadioButton("3000");

c.gridx = 4; c.gridy = 0;

pt.add(pr3, c);

sp3 = new JButton();

sp3.setBorder(BorderFactory.createEmptyBorder());

ImageIcon im3 = new ImageIcon((new


ImageIcon("E:\\img\\ex.jpg").getImage().getScaledInstance(30, 30, Image.SCALE_DEFAULT)));

sp3.setIcon(im3);

c.gridx = 5; c.gridy = 0;

pt.add(sp3);

ButtonGroup sel = new ButtonGroup();

sel.add(pr1); sel.add(pr2); sel.add(pr3);

c.gridx = 1; c.gridy = 3;

p1.add(pt, c);

sc = new JLabel("Service Charges : ");

c.gridx = 0; c.gridy = 4;

p1.add(sc, c);

sct = new JTextField(6);

c.gridx = 1; c.gridy = 4;

p1.add(sct, c);

crt = new JButton("Create");

c.gridx = 1; c.gridy = 5;

p1.add(crt, c);

Container contentPane = f.getContentPane();


pack();

f.setSize(500,500);

f.setDefaultCloseOperation(EXIT_ON_CLOSE);

@Override

public void actionPerformed(ActionEvent e) {

bp.setLayout(new GridBagLayout());

GridBagConstraints c = new GridBagConstraints();

if(e.getSource() == crto){

f.add(p1);

f.getContentPane().add(p1);

f.validate();

if(e.getSource() == prtbill){

String a,b = "";

bl.setText("Bill");

bl.setFont(new Font("Times New Roman", Font.PLAIN, 24));

check.setText(cn.getText() + cnt.getText());

mcn.setText("MemberShip : Customer. No of Visit : 1");

dat.setText("Date and Time : "+ d.getText());

scl.setText(sc.getText() + sct.getText());

pcl.setText("Product Charges : " + pr1.getText());

double te;

a = sct.getText();

if(pr1.isSelected()){

b = pr1.getText();
}

if(pr2.isSelected()){

b = pr2.getText();

if(pr3.isSelected()){

b = pr3.getText();

t.setText("Total : " +( Double.parseDouble(a) + Double.parseDouble(b)));

c.anchor = GridBagConstraints.CENTER;

c.gridx = 0; c.gridy = 1;

bp.add(bl, c);

c.gridx = 0; c.gridy = 2;

bp.add(check, c);

c.gridx = 0; c.gridy = 3;

bp.add(mcn, c);

c.gridx = 0; c.gridy = 4;

bp.add(dat, c);

c.gridx = 0; c.gridy = 5;

bp.add(scl, c);

c.gridx = 0; c.gridy = 6;

bp.add(pcl,c);

c.gridx = 0; c.gridy = 7;

bp.add(t, c);

f.add(bp);

f.getContentPane().remove(p1);

f.getContentPane().add(bp);

f.validate();
}

if(e.getSource() == lgot){

this.f.setVisible(false);

new Loginbox().setVisible(true);

class BillPanel extends JPanel{

//login

class Loginbox extends JFrame implements ActionListener{

JButton b1,b2,b;

JLabel un,up;

JTextField unt,unpp;

JPanel p ,pf;

JPanel p1;

Loginbox(){

try {

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

catch (Exception e) {

System.err.println(e.getMessage());

}
p = new JPanel();

p1 = new JPanel();

pf = new JPanel();

p.setLayout(new GridBagLayout());

GridBagConstraints c= new GridBagConstraints();

setTitle("Login"); setSize(550,195);

b = new JButton();

b.setBorder(BorderFactory.createEmptyBorder());

ImageIcon imgc = new ImageIcon(((new ImageIcon(

"E:\\img\\6.jpg").getImage()

.getScaledInstance(100, 100,java.awt.Image.SCALE_DEFAULT))));

b.setIcon(imgc);

p1.add(b);

un = new JLabel("User Name ");

c.gridx = 0; c.gridy = 0;

p.add(un , c);

unt = new JTextField(10);

c.gridx = 1; c.gridy = 0;

p.add(unt, c);

up = new JLabel("Password ");


c.gridx = 0; c.gridy = 1;

c.insets = new Insets(10,0,0,0);

p.add(up, c);

unpp = new JTextField(10);

c.gridx = 1; c.gridy = 1;

p.add(unpp, c);

b1 = new JButton("OK");b1.addActionListener(this);

c.insets = new Insets(10,0,0,0);

c.anchor = GridBagConstraints.LINE_START;

c.gridx = 0; c.gridy = 2;

p.add(b1, c);

b2 = new JButton("Cancel");b2.addActionListener(this);

c.gridx = 1; c.gridy = 2;

c.anchor = GridBagConstraints.LINE_END;

p.add(b2, c);

pf.add(p1);

pf.add(p);

this.getContentPane().add(pf);
pack();

setVisible(true);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

public void actionPerformed(ActionEvent e){

String user;

String pass;

if(e.getSource() == b2){

System.exit(0);

if(e.getSource() == b1){

user = unt.getText();

pass = unpp.getText();

if(user.equals("admin") && pass.equals("danish"))

this.setVisible(false);

new HairSaloon().f.setVisible(true);

else

JOptionPane.showMessageDialog(null, "username and password is not correct");

if(e.getSource() == b2){
System.exit(0);

You might also like