Thanks to visit codestin.com
Credit goes to www.scribd.com

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

ViewInformation Java

The document is a Java class named ViewInformation that extends JFrame and implements ActionListener for an electricity billing system. It displays customer information such as name, meter number, address, city, state, email, and phone number retrieved from a database based on a meter number. The class also includes a cancel button to close the window and an image related to customer viewing.
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)
5 views3 pages

ViewInformation Java

The document is a Java class named ViewInformation that extends JFrame and implements ActionListener for an electricity billing system. It displays customer information such as name, meter number, address, city, state, email, and phone number retrieved from a database based on a meter number. The class also includes a cancel button to close the window and an image related to customer viewing.
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

Electricity-Billing-System\src\electricity\billing\system\ViewInformation.

java

1 package electricity.billing.system;
2
3 import javax.swing.*;
4 import java.awt.*;
5 import java.sql.*;
6 import java.awt.event.*;
7
8 public class ViewInformation extends JFrame implements ActionListener{
9
10 JButton cancel;
11 ViewInformation(String meter) {
12 setBounds(350, 150, 850, 650);
13 getContentPane().setBackground(Color.WHITE);
14 setLayout(null);
15
16
17 JLabel heading = new JLabel("VIEW CUSTOMER INFORMATION");
18 heading.setBounds(250, 0, 500, 40);
19 heading.setFont(new Font("Tahoma", Font.PLAIN, 20));
20 add(heading);
21
22 JLabel lblname = new JLabel("Name");
23 lblname.setBounds(70, 80, 100, 20);
24 add(lblname);
25
26 JLabel name = new JLabel("");
27 name.setBounds(250, 80, 100, 20);
28 add(name);
29
30 JLabel lblmeternumber = new JLabel("Meter Number");
31 lblmeternumber.setBounds(70, 140, 100, 20);
32 add(lblmeternumber);
33
34 JLabel meternumber = new JLabel("");
35 meternumber.setBounds(250, 140, 100, 20);
36 add(meternumber);
37
38 JLabel lbladdress = new JLabel("Address");
39 lbladdress.setBounds(70, 200, 100, 20);
40 add(lbladdress);
41
42 JLabel address = new JLabel("");
43 address.setBounds(250, 200, 100, 20);
44 add(address);
45
46 JLabel lblcity = new JLabel("City");
47 lblcity.setBounds(70, 260, 100, 20);
48 add(lblcity);
49
50 JLabel city = new JLabel("");
51 city.setBounds(250, 260, 100, 20);
52 add(city);
53
54 JLabel lblstate = new JLabel("State");
55 lblstate.setBounds(500, 80, 100, 20);
56 add(lblstate);
57
58 JLabel state = new JLabel("");
59 state.setBounds(650, 80, 100, 20);
60 add(state);
61
62 JLabel lblemail = new JLabel("Email");
63 lblemail.setBounds(500, 140, 100, 20);
64 add(lblemail);
65
66 JLabel email = new JLabel("");
67 email.setBounds(650, 140, 100, 20);
68 add(email);
69
70 JLabel lblphone = new JLabel("Phone");
71 lblphone.setBounds(500, 200, 100, 20);
72 add(lblphone);
73
74 JLabel phone = new JLabel("");
75 phone.setBounds(650, 200, 100, 20);
76 add(phone);
77
78 try {
79 Conn c = new Conn();
80 ResultSet rs = c.s.executeQuery("select * from customer where meter_no =
'"+meter+"'");
81 while(rs.next()) {
82 name.setText(rs.getString("name"));
83 address.setText(rs.getString("address"));
84 city.setText(rs.getString("city"));
85 state.setText(rs.getString("state"));
86 email.setText(rs.getString("email"));
87 phone.setText(rs.getString("phone"));
88 meternumber.setText(rs.getString("meter_no"));
89 }
90 } catch (Exception e) {
91 e.printStackTrace();
92 }
93
94 cancel = new JButton("Cancel");
95 cancel.setBackground(Color.BLACK);
96 cancel.setForeground(Color.WHITE);
97 cancel.setBounds(350, 340, 100, 25);
98 add(cancel);
99 cancel.addActionListener(this);
100
101 ImageIcon i1 = new
ImageIcon(ClassLoader.getSystemResource("icon/viewcustomer.jpg"));
102 Image i2 = i1.getImage().getScaledInstance(600, 300, Image.SCALE_DEFAULT);
103 ImageIcon i3 = new ImageIcon(i2);
104 JLabel image = new JLabel(i3);
105 image.setBounds(20, 350, 600, 300);
106 add(image);
107
108 setVisible(true);
109 }
110
111 public void actionPerformed(ActionEvent ae) {
112 setVisible(false);
113 }
114
115 public static void main(String[] args) {
116 new ViewInformation("");
117 }
118 }
119

You might also like