java编写注册代码,Java代码编写

用Java编写注册登录程序

什么都不说了 直接给你代码吧

站在用户的角度思考问题,与客户深入沟通,找到东湖网站设计与东湖网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都做网站、成都网站建设、企业官网、英文网站、手机端网站、网站推广、主机域名雅安服务器托管、企业邮箱。业务覆盖东湖地区。

package com.moliying.ui;

import java.awt.BorderLayout;

import java.awt.Container;

import java.awt.FlowLayout;

import java.awt.List;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedWriter;

import java.io.FileOutputStream;

import java.io.OutputStreamWriter;

import java.util.ArrayList;

import java.util.Arrays;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class Login {

private JFrame frame = new JFrame("登录");

private Container c = frame.getContentPane();

private JTextField username = new JTextField();

private JPasswordField password = new JPasswordField();

private JButton ok = new JButton("确定");

private JButton cancel = new JButton("取消");

public Login() {

frame.setSize(300, 200);

frame.setBounds(450, 300, 300, 200);

c.setLayout(new BorderLayout());

initFrame();

frame.setVisible(true);

}

private void initFrame() {

// 顶部

JPanel titlePanel = new JPanel();

titlePanel.setLayout(new FlowLayout());

titlePanel.add(new JLabel("系统管理员登录"));

c.add(titlePanel, "North");

// 中部表单

JPanel fieldPanel = new JPanel();

fieldPanel.setLayout(null);

JLabel a1 = new JLabel("用户名:");

a1.setBounds(50, 20, 50, 20);

JLabel a2 = new JLabel("密 码:");

a2.setBounds(50, 60, 50, 20);

fieldPanel.add(a1);

fieldPanel.add(a2);

username.setBounds(110, 20, 120, 20);

password.setBounds(110, 60, 120, 20);

fieldPanel.add(username);

fieldPanel.add(password);

c.add(fieldPanel, "Center");

// 底部按钮

JPanel buttonPanel = new JPanel();

buttonPanel.setLayout(new FlowLayout());

buttonPanel.add(ok);

buttonPanel.add(cancel);

c.add(buttonPanel, "South");

ok.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

System.out.println(username.getText().toString());

}

});

cancel.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

frame.setVisible(false);

}

});

}

public static void main(String[] args) {

// new Login();

String ss = "abbabbbaabbbccba";

System.out.println(ss.split("b").length);

}

}

java编写一个登陆和注册信息的源代码,最简单的就可以,不需要数据库的那种

你这个不用数据库真的是有点难搞

我写了个用集合存储的,你看看,能否帮上你

java.util.ListString list = new ArrayListString();

list.add("qq=123");//存储的时候用(用户名=密码)的形式

list.add("ww=456");

String username = "qq";

String password = "123";

for (int i = 0; i  list.size(); i++) {

String num = username +"="+password;

if(num.equals(list.get(i))){

System.out.println("登录成功");

break;

}

}

如何用Java编写用户注册界面?

界面建议用可视化来做,美观且便捷。下面这个是完全用代码写的,仅供参考。

import javax.swing.*;

import java.awt.event.*;

import java.awt.*;

import java.sql.*;

public class Register extends JFrame {

JLabel jl1 = new JLabel("用户名");

JTextField jt1 = new JTextField();

JLabel jl2 = new JLabel("邮箱");

JTextField jt2 = new JTextField();

JLabel jl3 = new JLabel("密码");

JPasswordField jpw1 = new JPasswordField();

JLabel jl4 = new JLabel("密码确认");

JPasswordField jpw2 = new JPasswordField();

JButton register = new JButton("注册");

JButton clean = new JButton("清空");

public Register(){

setLayout(new GridLayout(5,2));

add(jl1);

add(jt1);

add(jl2);

add(jt2);

add(jl3);

add(jpw1);

add(jl4);

add(jpw2);

add(register);

add(clean);

String name = jt1.getText();

String email = jt2.getText();

String pw = jpw1.getText();

register.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

try{

Class.forName("com.mysql.jdbc.Driver");

Connection con = DriverManager.getConnection("jdbc:mysql://localhost/db","root","");

Statement sta = con.createStatement();

sta.executeUpdate("INSERT INTO register VALUES(name,email,pw)");

JOptionPane.showMessageDialog(null,"注册成功","提示",JOptionPane.INFORMATION_MESSAGE);

}

catch(Exception ex){

ex.getStackTrace();

}

}

});

clean.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

jt1.setText("");

jt2.setText("");

jpw1.setText("");

jpw2.setText("");

}

});

}

public static void main(String[] args){

Register frame = new Register();

frame.setTitle("用户注册");

frame.setLocationRelativeTo(null);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setSize(400,400);

frame.setVisible(true);

}

}

用java写一个手机商城注册界面代码

这篇文章主要介绍了java通过JFrame做一个登录系统的界面完整代码示例,具有一定借鉴价值,需要的朋友可以参考下。

在java的JFrame内通过创建匿名对象的方式做登录界面

package com.sxt;

import java.awt.Container;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class LoginFrame extends JFrame{

JTextField txtname=new JTextField();

JPasswordField txtpass=new JPasswordField();

JButton bl=new JButton("登录");

JButton bg=new JButton("关闭");

//构造无参构造器把主要的方法放在构造器里,然后在main方法里面调

public LoginFrame(){

setBounds(25,25,250,250);

Container c = getContentPane();

c.setLayout(new GridLayout(4,2,10,10));

c.add(new JLabel("用户名"));

c.add(txtname);

c.add(new JLabel("密码"));

c.add(txtpass);

c.add(bl);

c.add(bg);

setDefaultCloseOperation(EXIT_ON_CLOSE);

setVisible(true);

//注意:此处是匿名内部类

bg.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

System.exit(0);

}

}

);

//注意:此处是匿名内部类

bl.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {


新闻名称:java编写注册代码,Java代码编写
文章转载:http://myzitong.com/article/dsehisj.html