Java教程

Java项目:物业收费系统(java+Gui+文档)

本文主要是介绍Java项目:物业收费系统(java+Gui+文档),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

功能介绍:

用户登陆、用户注册、收费记录、生成业单、用户管理、查询缴费、历史账单、资料设置

 

 

 

用户登录业务操作:

// 用户登录业务操作

public class LoginFrame extends JFrame {

	private JPanel contentPane;
	private JTextField u_name_Field;
	private JPasswordField u_password_field;
	private user user;

	//登录事件监听器
	class loginAction implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			user = ExecuteSQL.check(u_name_Field.getText(), u_password_field.getText());
			if (user.getName() != null) {
				if (user.getPassword().equals(u_password_field.getText())) {
					try {
						atmFrame frame = new atmFrame(user.getName());
						frame.setTitle(user.getName());
						frame.setVisible(true);
						setVisible(false);
					} catch (Exception ex) {
						ex.printStackTrace();
					}
				} else {
					JOptionPane.showMessageDialog(null, "密码不正确!请重新输入");
					u_name_Field.setText("");
					u_password_field.setText("");
				}

			} else {
				JOptionPane.showMessageDialog(null, "找不到该用户,请先注册!");
				u_name_Field.setText("");
				u_password_field.setText("");
			}
		}
	}
	
	//注册事件监听器
	class signAction implements ActionListener{

		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			SignFrame frame = new SignFrame();
			frame.setVisible(true);
			setVisible(false);
		}
		
	}

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					LoginFrame frame = new LoginFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public LoginFrame() {
		setTitle("\u7F51\u4E0A\u94F6\u884C");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 506, 385);
		contentPane = new JPanel();
		setLocationRelativeTo(null);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton LoginButton = new JButton("\u767B\u5F55");
		LoginButton.setFont(new Font("新宋体", Font.BOLD, 20));
		LoginButton.setBounds(92, 214, 120, 37);
		contentPane.add(LoginButton);
		LoginButton.addActionListener(new loginAction());
		
		JButton signButton = new JButton("\u6CE8\u518C");
		signButton.setFont(new Font("新宋体", Font.BOLD, 20));
		signButton.setBounds(283, 214, 113, 37);
		contentPane.add(signButton);
		signButton.addActionListener(new signAction());
		
		JLabel u_nameLabel = new JLabel("\u7528\u6237\u540D\uFF1A");
		u_nameLabel.setFont(new Font("新宋体", Font.BOLD, 18));
		u_nameLabel.setBounds(92, 49, 88, 37);
		contentPane.add(u_nameLabel);
		
		JLabel u_passwordLabel_1 = new JLabel("\u5BC6\u7801\uFF1A");
		u_passwordLabel_1.setFont(new Font("新宋体", Font.BOLD, 18));
		u_passwordLabel_1.setBounds(92, 130, 88, 27);
		contentPane.add(u_passwordLabel_1);
		
		u_name_Field = new JTextField();
		u_name_Field.setBounds(184, 57, 157, 29);
		contentPane.add(u_name_Field);
		u_name_Field.setColumns(10);
		
		u_password_field = new JPasswordField();
		u_password_field.setBounds(184, 133, 157, 27);
		contentPane.add(u_password_field);
		
		JLabel lblNewLabel = new JLabel("\u7528\u6237\u6307\u5357");
		lblNewLabel.setForeground(Color.RED);
		lblNewLabel.setBounds(402, 307, 72, 31);
		contentPane.add(lblNewLabel);
	}
}



用户注册业务操作:

//用户注册业务操作

public class SignFrame extends JFrame {

	private JPanel contentPane;
	private JTextField u_name;
	private JPasswordField u_password;
	private JPasswordField u_password_1;
	private user user;

	
	//注册按钮监听器
	class OKButtonAction implements ActionListener {

		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			if (!u_name.getText().equals("")) {
				if (!u_password.getText().equals("")) {
					if (!u_password_1.getText().equals("")) {
						if (u_password.getText().equals(u_password_1.getText())) {
							user = ExecuteSQL.check(u_name.getText(), u_password.getText());
							if (!u_name.getText().equals(user.getName())) {
								 ExecuteSQL.addUser(u_name.getText(), u_password.getText());
								setVisible(false);
								LoginFrame frame = new LoginFrame();
								frame.setVisible(true);
								JOptionPane.showMessageDialog(null, "注册成功,可以继续登录!");
							} else {
								JOptionPane.showMessageDialog(null, "用户名已经存在!");
							}
						} else {
							JOptionPane.showMessageDialog(null, "密码确认不符!");
						}

					} else {
						JOptionPane.showMessageDialog(null, "未输入确认密码!");
					}

				} else {
					JOptionPane.showMessageDialog(null, "未输入密码!");
				}
			} else {
				JOptionPane.showMessageDialog(null, "未输入用户名!");
			}
		}

	}

	/**
	 * Create the frame.
	 */
	public SignFrame() {
		setTitle("\u7528\u6237\u6CE8\u518C");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 364);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		setLocationRelativeTo(null);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("\u7528\u6237\u540D\uFF1A");
		lblNewLabel.setFont(new Font("新宋体", Font.BOLD, 18));
		lblNewLabel.setBounds(74, 78, 102, 34);
		contentPane.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("\u5BC6\u7801\uFF1A");
		lblNewLabel_1.setFont(new Font("新宋体", Font.BOLD, 18));
		lblNewLabel_1.setBounds(88, 149, 88, 28);
		contentPane.add(lblNewLabel_1);
		
		JLabel lblNewLabel_2 = new JLabel("\u786E\u8BA4\u5BC6\u7801\uFF1A");
		lblNewLabel_2.setFont(new Font("新宋体", Font.BOLD, 18));
		lblNewLabel_2.setBounds(69, 211, 101, 28);
		contentPane.add(lblNewLabel_2);
		
		u_name = new JTextField();
		u_name.setBounds(187, 85, 123, 24);
		contentPane.add(u_name);
		u_name.setColumns(10);
		
		u_password = new JPasswordField();
		u_password.setBounds(187, 153, 123, 24);
		contentPane.add(u_password);
		
		u_password_1 = new JPasswordField();
		u_password_1.setBounds(187, 215, 123, 24);
		contentPane.add(u_password_1);
		
		JButton OKButton = new JButton("\u786E\u5B9A");
		OKButton.setFont(new Font("新宋体", Font.BOLD, 20));
		OKButton.setBounds(171, 277, 113, 27);
		contentPane.add(OKButton);
		OKButton.addActionListener(new OKButtonAction());
	}
}

这篇关于Java项目:物业收费系统(java+Gui+文档)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!