「java登录服务设计」java用户登录界面设计

博主:adminadmin 2023-03-17 07:55:06 452

今天给各位分享java登录服务设计的知识,其中也会对java用户登录界面设计进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

求JAVA编程,做一个用户登录系统的设计!

import java.awt.HeadlessException;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;@SuppressWarnings("serial")public class MainFrame extends JFrame { JLabel lbl1 = new JLabel("用户名:"); JLabel lbl2 = new JLabel("密 码:"); JTextField txt = new JTextField("admin",20); JPasswordField pwd = new JPasswordField(20); JButton btn = new JButton("登录"); JPanel pnl = new JPanel(); private int error = 0; public MainFrame(String title) throws HeadlessException { super(title); init(); } private void init() { this.setResizable(false); pwd.setEchoChar('*'); pnl.add(lbl1); pnl.add(txt); pnl.add(lbl2); pnl.add(pwd); pnl.add(btn); this.getContentPane().add(pnl); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if ("admin".equals(new String(pwd.getPassword()))){ pnl.removeAll(); JLabel lbl3 = new JLabel(); ImageIcon icon = new ImageIcon(this.getClass().getResource("pic.jpg")); lbl3.setIcon(icon); pnl.add(lbl3); } else{ if(error 3){ JOptionPane.showMessageDialog(null,"密码输入错误,请再试一次"); error++; } else{ JOptionPane.showMessageDialog(null,"对不起,您不是合法用户"); txt.setEnabled(false); pwd.setEnabled(false); btn.setEnabled(false); } } } }); } public static void main(String[] args) { MainFrame frm = new MainFrame("测试"); frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frm.setBounds(100, 100, 300, 120); frm.setVisible(true); }}

java用户登录界面的设计?

import javax.swing.*;

import java.awt.*;

public class Frame extends JFrame {

public static void main(String[] args) {

new Frame();

}

public Frame() throws HeadlessException {

Container contentPanel = this.getContentPane();

JPanel headerPanel = new JPanel();

headerPanel.setLayout(new FlowLayout());

headerPanel.add(new JLabel("欢迎进入学生成绩管理系统"));

JPanel centerPanel = new JPanel();

centerPanel.setLayout(new GridLayout(2, 2));

centerPanel.add(new JLabel("用户名", JLabel.CENTER));

centerPanel.add(new JTextField());

centerPanel.add(new JLabel("密码", JLabel.CENTER));

centerPanel.add(new JTextField());

JPanel footerPanel = new JPanel();

footerPanel.setLayout(new FlowLayout());

footerPanel.add(new JButton("登录"));

footerPanel.add(new JButton("取消"));

contentPanel.add(headerPanel, BorderLayout.NORTH);

contentPanel.add(centerPanel, BorderLayout.CENTER);

contentPanel.add(footerPanel, BorderLayout.SOUTH);

this.setTitle("Login");

this.setBounds(0, 0, 300, 200);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

}

}

java实验:用户登录系统设计

1-你要写一个javabean用来封装用户登陆时的信息

2-在数据库中建好库和表

3-使用servlet的话,要在web.xml做相应的路径映射配置,然后页面form的action写这个servlet的地址,页面提交后到servlet,然后根据提交的用户名查询数据库,返回的用户对象封装到第一步写的javabean里,读取返回的用户对象的密码与登陆时传到servlet的密码验证,成功后将用户对象放入session然后跳转到下一个页面,不成功,返回登陆页面然后通过js或者其他方法提示登陆失败和原因

关于java登录服务设计和java用户登录界面设计的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。