java淘宝登录界面代码 java淘宝登录界面代码是什么

用java做好的登陆界面,当登陆成功后跳转到下个页面的代码是什么?用java做好java淘宝登录界面代码的登陆界面java淘宝登录界面代码,当登陆成功后跳转到下个页面的代码如下:
如果登陆验证是在jsp中java淘宝登录界面代码,那么跳转可以写成
1.response.sendRedirct("跳转到页面");
2.jsp:forward page="跳转页面"/
3.response.setHeader("Location","");
如果是登陆验证是在servlet中,那么中转可以写成
1.response.sendRedirect("/a.jsp");
2.RequestDispatcher dispatcher = request.getRequestDispatcher("/a.jsp");
dispatcher .forward(request, response);
也可以使用js代码实现:
script
function validate(){
window.location.href="https://www.04ip.com/index.jsp";
}
/script
登陆界面的java代码怎么写?import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
class LoginFrm extends JFrame implements ActionListener
{
JLabel lbl1=new JLabel("用户名");
JLabel lbl2=new JLabel("密码");
JTextField txt=new JTextField(15);
JPasswordField pf=new JPasswordField();
JButton btn1=new JButton("确定");
JButton btn2=new JButton("取消");
public LoginFrm()
{
this.setTitle("登陆");
JPanel jp=(JPanel)this.getContentPane();
jp.setLayout(new GridLayout(3,2,10,10));
jp.add(lbl1);jp.add(txt);
jp.add(lbl2);jp.add(pf);
jp.add(btn1);jp.add(btn2);
btn1.addActionListener(this);
btn2.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==btn1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")java淘宝登录界面代码;
Connection con=DriverManager.getConnection("jdbc:odbc:MyDB","","");
Statement cmd=con.createStatement();
ResultSet rs=cmd.executeQuery("select * from loginAndpassword where login='" txt.getText() "' and password='" pf.getText() "'");
if(rs.next())
{
JOptionPane.showMessageDialog(null,"登陆成功java淘宝登录界面代码!");
}
else
JOptionPane.showMessageDialog(null,"用户名或密码错误java淘宝登录界面代码!");
} catch(Exception ex){}
if(ae.getSource()==btn2)
{
txt.setText("");
pf.setText("");
}
}
}
public static void main(String arg[])
{
JFrame.setDefaultLookAndFeelDecorated(true);
LoginFrm frm=new LoginFrm();
frm.setSize(400,200);
frm.setVisible(true);
}
}
用Java设计一个登录页面,不用连接数据库,只要把用户和密码信息存放在文本里面,怎样设计代码???/* Main.java
*
* Created on __DATE__, __TIME__
*/
【java淘宝登录界面代码 java淘宝登录界面代码是什么】import javax.swing.JOptionPane;
/**
*
* @author__USER__
*/
public class Main extends javax.swing.JFrame {
/** Creates new form Main */
public Main() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
// editor-fold defaultstate="collapsed" desc="Generated Code"
private void initComponents() {
jPanel1 = new javax.swing.JPanel();//标签
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();//登录按钮
jButton2 = new javax.swing.JButton();//
jTextField1 = new javax.swing.JTextField();//文本框
jTextField2 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);//关闭时的操作,即退出程序
setTitle("登录界面");//设置标题:欢迎使用股票管理系统
setResizable(false);//设置窗口不可调节大小
jLabel1.setFont(new java.awt.Font("微软雅黑", 0, 18));//设置标签的字体
jLabel1
.setText("您好,请输入信息");
jLabel2.setText("用户名");
jLabel3.setText("用户密码");
jButton1.setText("登录");
jButton1.addActionListener(new java.awt.event.ActionListener() {//采用匿名内部类来实现按钮监听功能
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("退出");
jButton2.addActionListener(new java.awt.event.ActionListener() {//同上
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(//层次布局管理器,下面n长的代码 , 就是设置位置,自己看吧,呵呵 , 这个必须的 , 就不多写了
jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout
.setHorizontalGroup(jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(159, Short.MAX_VALUE)
.addComponent(jLabel1).addGap(140, 140,
140))
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addGap(110, 110, 110)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(54, 54, 54)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addComponent(
jTextField2,
javax.swing.GroupLayout.DEFAULT_SIZE,
191,
Short.MAX_VALUE)
.addGap(
112,
112,
112))
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addComponent(
jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE,
191,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addGap(141, 141, 141)
.addComponent(
jButton1,
javax.swing.GroupLayout.PREFERRED_SIZE,
68,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(89, 89, 89)
.addComponent(
jButton2,
javax.swing.GroupLayout.PREFERRED_SIZE,
72,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(145, Short.MAX_VALUE)));
jPanel1Layout
.setVerticalGroup(jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(55, 55, 55)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(
jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(41, 41, 41)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(
jTextField2,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(43, 43, 43)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(
jButton1,
javax.swing.GroupLayout.PREFERRED_SIZE,
33,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(
jButton2,
javax.swing.GroupLayout.PREFERRED_SIZE,
33,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(48, Short.MAX_VALUE)));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addGroup(
layout.createSequentialGroup().addContainerGap().addComponent(
jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap()));
layout.setVerticalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addGroup(
layout.createSequentialGroup().addContainerGap().addComponent(
jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)));
pack();
setLocationRelativeTo(null);//居中
}// /editor-fold
//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//事件处理,不建议这样做
// TODO add your handling code here:
String name = this.jTextField1.getText().trim();//获得用户名,去空格
String password = this.jTextField2.getText().trim();//获得密码,去空格
if (name.equals("admin")password.equals("123456")) {//如果符合条件.....其实这里应该去和数据库关联,这是死代码
//Showinformation sf=new Showinformation();//我估计是另外一个框架 , 就是登录成功之后的框架
//sf.setVisible(true);
//sf.show();//这个方法就直接秒杀,不用了,因为sf.setVisible(true)已经被调用了,这里就多次一举了
} else {//用户名或者密码验证失败
JOptionPane.showMessageDialog(this, "用户名或者密码错误啦~", "提示",//提示框
JOptionPane.INFORMATION_MESSAGE);
this.jTextField1.setText("");//清空输入框
this.jTextField2.setText("");
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//事件处理,其实可以将jButton1ActionPerformed放在一起处理,只要获得按钮的标签内容(JButton)(evt.getSuorse()).getText()就做对比就ko了
// TODO add your handling code here:
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {//好方法,呵呵使用该方式的原因是:awt是单线程模式的 , 所有awt的组件只能在(推荐方式)事件处理线程中访问,从而保证组件状态的可确定性 。java核心编程技术中每个实例基本都用到了
public void run() {
new Main().setVisible(true);
}
});
}
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;}
// End of variables declaration//GEN-END:variables
你修改一下吧 , 从记事本获得用户名判断一下就行了
求Java编的登录界面代码:登录后分别进入管理员界面及用户界面,依据是数据库中的用户名和密码分三个包 , 自己建个包,导进去就ok了,数据库是access的 。
package 登录;
import java.awt.EventQueue;
public class Cilent {
private JFrame frame;
private JTextField textField;
private JPasswordField passwordField;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Cilent window = new Cilent();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Cilent() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setTitle("登陆界面");
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
frame.setResizable(false);
JLabel lblNewLabel = new JLabel("用户名");
lblNewLabel.setBounds(38, 43, 80, 34);
frame.getContentPane().add(lblNewLabel);
textField = new JTextField();
textField.setBounds(155, 42, 227, 37);
frame.getContentPane().add(textField);
textField.setColumns(10);
JLabel label = new JLabel("密 码");
label.setBounds(38, 115, 80, 34);
frame.getContentPane().add(label);
passwordField = new JPasswordField();
passwordField.setBounds(155, 115, 227, 37);
frame.getContentPane().add(passwordField);
JButton btnNewButton = new JButton("登 录");
btnNewButton.setBounds(60, 187, 115, 34);
frame.getContentPane().add(btnNewButton);
btnNewButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
UserCheck UC=new UserCheck(textField.getText(),String.valueOf(passwordField.getPassword()));
if(UC.getI()!=0)//有此用户
{
frame.setVisible(false);
}
else
{
textField.setText("");
passwordField.setText("");
}
}
});
JButton button = new JButton("取 消");
button.setBounds(242, 187, 115, 34);
frame.getContentPane().add(button);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
textField.setText("");
passwordField.setText("");
}
});
}
}
/*****************************************************************/
package 登录;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import 操作处理.UsersCL;
/**@author 20111024
* 检测登录的用户在数据库中有无,若没有,则提示没有此用户,
* 若有,则判断级别:普通用户还是管理员 。
*/
public class UserCheck {
private int i=0;//用户级别:0不是用户、1是管理员、2是普通用户
UserCheck(String name ,String password)
{
String jdriver="sun.jdbc.odbc.JdbcOdbcDriver";
String connectDB="jdbc:odbc:Students";
Statement stmt=null;
ResultSet rs=null;
Connection con=null;
try {
Class.forName(jdriver);
con=DriverManager.getConnection(connectDB);
stmt=con.createStatement();
String query="select * from users where name='" name "' and passwd='" password "'";
rs=stmt.executeQuery(query);
if(rs.next())
{
//数据库中有此用户,访问成功
i=Integer.parseInt(rs.getString(3));
UsersCL UL=new UsersCL(i);
}
else
{
i=0;//没有用户是默认是0级
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public int getI() {
return i;
}
}
/********************************************************************************************/
package 操作处理;
import java.awt.EventQueue;
public class UsersCL implements ActionListener{
private JFrame frame;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;
private int i=0;
private JLabel label_3;
private JTextField textField_4;
public UsersCL(int i) {
this.i=i;
frame = new JFrame();
frame.setTitle("用户处理界面");
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
frame.setResizable(false);
frame.setVisible(true);
JLabel lblNewLabel = new JLabel("学 号");
lblNewLabel.setBounds(24, 32, 74, 29);
frame.getContentPane().add(lblNewLabel);
JLabel label = new JLabel("姓 名");
label.setBounds(24, 71, 74, 29);
frame.getContentPane().add(label);
JLabel label_1 = new JLabel("年 龄");
label_1.setBounds(24, 110, 74, 29);
frame.getContentPane().add(label_1);
label_3 = new JLabel("性 别");
label_3.setBounds(24, 149, 74, 29);
frame.getContentPane().add(label_3);
JLabel label_2 = new JLabel("状 态");
label_2.setBounds(24, 195, 74, 29);
frame.getContentPane().add(label_2);
textField = new JTextField();
textField.setBounds(101, 34, 113, 25);
frame.getContentPane().add(textField);
textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setColumns(10);
textField_1.setBounds(101, 73, 113, 25);
frame.getContentPane().add(textField_1);
textField_2 = new JTextField();
textField_2.setColumns(10);
textField_2.setBounds(101, 112, 113, 25);
frame.getContentPane().add(textField_2);
textField_3 = new JTextField();
textField_3.setEditable(false);
textField_3.setColumns(10);
textField_3.setBounds(101, 199, 288, 25);
frame.getContentPane().add(textField_3);
textField_4 = new JTextField();
textField_4.setColumns(10);
textField_4.setBounds(101, 149, 113, 25);
frame.getContentPane().add(textField_4);
if(1==i)
{
JButton btnNewButton = new JButton("追 加");
btnNewButton.setBounds(276, 41, 113, 29);
frame.getContentPane().add(btnNewButton);
btnNewButton.addActionListener(this);
btnNewButton.setActionCommand("追加");
JButton button_1 = new JButton("删 除");
button_1.setBounds(276, 145, 113, 29);
frame.getContentPane().add(button_1);
button_1.addActionListener(this);
button_1.setActionCommand("删除");
}
JButton button = new JButton("查 询");
button.setBounds(276, 91, 113, 29);
frame.getContentPane().add(button);
button.addActionListener(this);
button.setActionCommand("查询");
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
String name,age,sex,query=null;
int num,age1,count=0;
num=Integer.parseInt(textField.getText());
name=textField_1.getText();
age1=Integer.parseInt(textField_2.getText());
sex=textField_4.getText();
if(e.getActionCommand().equals("追加"))
{
query="insert into students values(" num "," "'" name "'," age1 ",'" sex "');";
count=1;
}
else if(e.getActionCommand().equals("查询"))
{
query="select * from students where XSB=" num ";";
count=2;
}
else if(e.getActionCommand().equals("删除"))
{
query="delete from students where XSB=" num " and name=" "'" name "'";
count=3;
}
Statement stmt=null;
ResultSet rs=null;
Connection con=null;
String jdriver="sun.jdbc.odbc.JdbcOdbcDriver";
String connectDB="jdbc:odbc:Students";
String query1=null;
try {
Class.forName(jdriver);
con=DriverManager.getConnection(connectDB);
stmt=con.createStatement();
if(count==1)
{
query1="select * from students where XSB=" num ";";
rs=stmt.executeQuery(query1);
if(rs.next())
textField_3.setText("已经由此记录 , 不能追加!");
else
{
stmt.executeUpdate(query);
textField_3.setText("已经追加完成!");
}
}
else if(2==count)
{
stmt.executeQuery(query);
rs=stmt.executeQuery(query);
if(rs.next())
{
textField_3.setText("已查找到此记录!");
}
else
{
textField_3.setText("没有此记录,可以追加!");
}
}
else if(3==count)
{
query1="select * from students where XSB=" num " and name=" "'" name "'";
rs=stmt.executeQuery(query1);
if(rs.next())
{
stmt.executeUpdate(query);
textField_3.setText("已删除此记录!");
}
else
textField_3.setText("无此记录!");
}
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
finally{
//关闭资源
if(stmt!=null){
try {
stmt.close();
} catch (Exception e2) {
// TODO: handle exception
}
stmt=null;
}
if(con!=null){
try {
con.close();
} catch (Exception e2) {
// TODO: handle exception
}
con=null;
}
}
}
}
用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代码淘宝页面价格变化怎样写你可以使用JavaScript来实现这个功能 。首先,你需要在页面中添加一个JavaScript函数,该函数将会在每次价格变化时被调用 。这个函数可以使用AJAX来发起一个请求 , 以获取最新的价格信息 。然后,该函数可以使用DOM操作来更新页面上的价格显示 。你可以使用setInterval()函数来定期调用这个函数,以获取最新的价格信息 。
关于java淘宝登录界面代码和java淘宝登录界面代码是什么的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读