大学生社团信息管理系统(3)

2020-02-21 20:57

}

}

{

return true;

}else { }

return false;

public static boolean isNotEmpty(String str) { }

if(!\{

return true;

}else { }

return false;

7

4登录模块设计

4.1登录模块概述

运行程序,首先进入系统登录窗口。为了使窗体中的各个组件放得更加随意美观,因此本次系统设计采用了绝对布局方式,并在窗体中添加了背景图片,运行结果可以参照图1.1.

4.2实现带背景的窗体

在创建窗体时,需要向窗体中添加面板,然后在面板中添加各种组件。Swing中代表面板组件的类为JPanel,该类是以灰色为背景,并且没有任何图片,这样就不能达到很好的美观效果。因此该登录窗口所运用的就是面板的叠加,把图片添加到了JLabel中,然后把JLabel添加到面板中,并且带背景图片的面板放在了最低层,并且该面板透明度设置为不透明,这样就可以实现带背景图片的登录窗口,具体代码如下:

package com.zky.www.view;

public class LoginFrame extends JFrame{

private JLabel lbUsername=new JLabel(\用户名:\实例变量 private JTextField txtUsername=new JTextField();

private JLabel lbPassword=new JLabel(\密 码:\private JPasswordField txtPassword=new JPasswordField(); private JButton btnLogin=new JButton(\登录\

private JButton btnCancel=new JButton(\取消\

private JLabel lbTip=new JLabel(\大学生社团信息管理系统登录\

private DBUtil dbUtil=new DBUtil(); private UserDao userDao=new UserDao();

private static User mainUser=null;

LoginFrame()

{

8

ImageIcon background=new ImageIcon(\

JLabel imagLabel=new JLabel(background); this.setSize(800, 600);//设置大小

this.setLocationRelativeTo(null);//放在屏幕中间 this.setResizable(false);//不可改变大小

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置关闭属性 Container cont=this.getContentPane(); cont.setLayout(null);//自定义布局

lbTip.setFont(new Font(\黑体\lbTip.setForeground(Color.BLUE); lbTip.setBounds(0, 30, 800, 100); cont.add(lbTip);

lbUsername.setBounds(150, 200, 100, 25);

lbUsername.setFont(new Font(\宋体\txtUsername.setBounds(280, 200, 250, 28); cont.add(lbUsername); cont.add(txtUsername);

lbPassword.setBounds(150, 290, 100, 25);

lbPassword.setFont(new Font(\宋体\txtPassword.setBounds(280, 290, 250, 28); cont.add(lbPassword); cont.add(txtPassword);

btnLogin.setBounds(210, 380, 80, 25); btnCancel.setBounds(400, 380, 80, 25);

btnLogin.addActionListener(new LoginAction()); btnLogin.setFont(new Font(\宋体\btnCancel.addActionListener(new CancelAction()); btnCancel.setFont(new Font(\宋体\cont.add(btnLogin); cont.add(btnCancel);

9

}

this.getLayeredPane().add(imagLabel,newInteger(Integer.MIN_VALUE)); }

public static User getMainUser() { }

public static void setMainUser(User mainUser) { }

public static void main(String[] args) { }

new LoginFrame();

LoginFrame.mainUser = mainUser; return mainUser;

imagLabel.setBounds(0, 0, this.getWidth(), this.getHeight()); cont.add(imagLabel);

this.setVisible(true); //可见性

4.3登录模块实现过程

登录窗口设计十分简单,有一个用户名文本框,一个密码文本框,一个登录按钮和一个取消按钮组成。下面将实现介绍登录模块的实现过程。

(1)实现用户登录操作的数据表是user,首先创建与数据表对应的JaveBeen类User,该类中属性与数据表中字段一一对应,并包含了属性的get与set方法,具体代码如下:

package com.zky.www.model; public class User {//javabean

private int userId; private String username; private String password;

public User(int userId, String username, String password) {

super();

this.userId = userId;

10

}

}

this.username = username; this.password = password;

public User(String username, String password) { }

public User() { }

public int getUserId() { }

public void setUserId(int userId) { }

public String getUsername() { }

public void setUsername(String username) { }

public String getPassword() { }

public void setPassword(String password) { }

11

super();

this.username = username; this.password = password;

super();

return userId;

this.userId = userId;

return username;

this.username = username;

return password;

this.password = password;


大学生社团信息管理系统(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:小学数学

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: