❶ 求用java編寫的登陸界面!

這是我剛做的,JAVA布局與其它語言相比難度較大,建議你將兩張圖片PS成一張圖片,做為背景,加入到JFRAME中,以降低難度。

要是這個你喜歡,不要忘記多給我加分啊!!!

importjava.awt.*;

importjava.awt.event.*;

importjavax.swing.*;

importjavax.swing.border.*;

{

JTextFieldf1;

JTextFieldf2;

JButtonb1;

JButtonb2;

Stringpower;//表示許可權

StringimgePath="e:/workspace/GUI/14.gif";

JPanelp5;

Imageimg=Toolkit.getDefaultToolkit().createImage(imgePath);

LoginIn(){

Containercp=getContentPane();

Labell1=newLabel("用戶:");

Labell2=newLabel("密碼:");

JPanelp1=newJPanel();

JPanelp2=newJPanel();

JPanelp3=newJPanel();

JPanelp4=newJPanel();

p5=newJPanel(){

protectedvoidpaintChildren(Graphicsg){

g.drawImage(img,0,0,this);

super.paintChildren(g);

}

};

f1=newJTextField(15);

f2=newJPasswordField(15);

b1=newJButton("登錄");

b2=newJButton("重置");

p1.setBackground(Color.orange);

p2.add(l1);

p2.add(f1);

p2.setBorder(newMatteBorder(0,0,0,0,Color.BLACK));

p2.setBackground(Color.ORANGE);

p3.add(l2);

p3.add(f2);

p3.setBackground(Color.ORANGE);

p3.setBorder(newMatteBorder(0,0,0,0,Color.BLACK));

p4.add(b1);

p4.add(b2);

p4.setBorder(newMatteBorder(-3,-3,-3,-3,Color.CYAN));

p4.setBackground(Color.ORANGE);

p5.setLayout(newFlowLayout(FlowLayout.CENTER,20,20));

p5.add(p2);

p5.add(p3);

p5.add(p4);

cp.add(p5,BorderLayout.CENTER);

b1.addActionListener(newEnter());

b2.addActionListener(newReWrite());

addWindowListener(newwinClose());

}

publicstaticvoidmain(String[]args){

LoginInlog=newLoginIn();

log.setTitle("系統登錄");

log.setSize(360,250);

log.setVisible(true);

}

{

publicvoidactionPerformed(ActionEvente)

{

if((f1.getText()).equals("admin")&&(f2.getText()).equals("123"))

{

JOptionPane.showMessageDialog(null,"登錄成功!用戶許可權是adimistrator");

power="adminstrator";

}

elseif((f1.getText()).equals("snake")&&(f2.getText()).equals("123456"))

{

JOptionPane.showMessageDialog(null,"登錄成功!登錄成功!用戶許可權是user");

power="adminstrator";

}

elseJOptionPane.showMessageDialog(null,"登錄失敗,請重新登錄!");

}

}

{

publicvoidactionPerformed(ActionEvente)

{

f1.setText("");

f2.setText("");

f1.requestFocus();

}

}

{

publicvoidwindowClosing(WindowEvente)

{

(e.getWindow()).dispose();

System.exit(0);

}

}

}

❷ 用java編寫登錄界面,求操作

Java會,但GUI沒學過,所以,只能無奈表示幫不上忙。
但是其他語言界面開發應該與GUI開發類似。
應當有相應的布局和窗口組件,並給登錄按鈕添加單擊事件。在單擊事件方法當中寫讀取用戶名和密碼的代碼。然後與指定的內容進行比較。比較通過,注銷該窗口;比較不通過,繼續保持該窗口即可。
這樣的窗口,通過一些窗口設計軟體應該很容易實現。

❸ java編寫登陸界面

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Toolkit;

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 extends JFrame{

private JPanel jp1,jp2,jp3;
private JButton jbtnLogin;
private JLabel jlbUser,jlbPasswd;
private JPasswordField jpfPasswd;
private JTextField jtfUser;

public static void main(String[] args) {
// TODO Auto-generated method stub
new Login();
}

public Login()
{
jp1 = new JPanel(new BorderLayout());
jp2 = new JPanel(new GridLayout(2,2));
jp3 = new JPanel();
jbtnLogin = new JButton("登錄");
jlbUser = new JLabel("用戶名:");
jlbPasswd = new JLabel("密碼:");
jtfUser = new JTextField();
jpfPasswd = new JPasswordField();
jp3.add(jbtnLogin);
jp2.add(jlbUser);
jp2.add(jtfUser);
jp2.add(jlbPasswd);
jp2.add(jpfPasswd);
jp1.add(jp2);
jp1.add(jp3,"South");
this.add(jp1);
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocation(width/2-200, height/2-150);
this.setSize(400, 150);
}
}

❹ java實現簡單登錄界面

自己寫的比較規范的代碼,都有注釋:

import javax.swing.JFrame;//框架
import javax.swing.JPanel;//面板
import javax.swing.JButton;//按鈕
import javax.swing.JLabel;//標簽
import javax.swing.JTextField;//文本框
import java.awt.Font;//字體
import java.awt.Color;//顏色
import javax.swing.JPasswordField;//密碼框
import java.awt.event.ActionListener;//事件監聽
import java.awt.event.ActionEvent;//事件處理
import javax.swing.JOptionPane;//消息窗口

public class UserLogIn extends JFrame{
public JPanel pnluser;
public JLabel lbluserLogIn;
public JLabel lbluserName;
public JLabel lbluserPWD;
public JTextField txtName;
public JPasswordField pwdPwd;
public JButton btnSub;
public JButton btnReset;

public UserLogIn(){
pnluser = new JPanel();
lbluserLogIn = new JLabel();
lbluserName = new JLabel();
lbluserPWD = new JLabel();
txtName = new JTextField();
pwdPwd = new JPasswordField();
btnSub = new JButton();
btnReset = new JButton();
userInit();
}

public void userInit(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//設置關閉框架的同時結束程序
this.setSize(300,200);//設置框架大小為長300,寬200
this.setResizable(false);//設置框架不可以改變大小
this.setTitle("用戶登錄");//設置框架標題
this.pnluser.setLayout(null);//設置面板布局管理
this.pnluser.setBackground(Color.cyan);//設置面板背景顏色
this.lbluserLogIn.setText("用戶登錄");//設置標簽標題
this.lbluserLogIn.setFont(new Font("宋體",Font.BOLD | Font.ITALIC,14));//設置標簽字體
this.lbluserLogIn.setForeground(Color.RED);//設置標簽字體顏色
this.lbluserName.setText("用戶名:");
this.lbluserPWD.setText("密 碼:");
this.btnSub.setText("登錄");
this.btnReset.setText("重置");
this.lbluserLogIn.setBounds(120,15,60,20);//設置標簽x坐標120,y坐標15,長60,寬20
this.lbluserName.setBounds(50,55,60,20);
this.lbluserPWD.setBounds(50,85,60,25);
this.txtName.setBounds(110,55,120,20);
this.pwdPwd.setBounds(110,85,120,20);
this.btnSub.setBounds(85,120,60,20);
this.btnSub.addActionListener(new ActionListener()//匿名類實現ActionListener介面
{
public void actionPerformed(ActionEvent e){
btnsub_ActionEvent(e);
}
}
);
this.btnReset.setBounds(155,120,60,20);
this.btnReset.addActionListener(new ActionListener()//匿名類實現ActionListener介面
{
public void actionPerformed(ActionEvent e){
btnreset_ActionEvent(e);
}
}
);
this.pnluser.add(lbluserLogIn);//載入標簽到面板
this.pnluser.add(lbluserName);
this.pnluser.add(lbluserPWD);
this.pnluser.add(txtName);
this.pnluser.add(pwdPwd);
this.pnluser.add(btnSub);
this.pnluser.add(btnReset);
this.add(pnluser);//載入面板到框架
this.setVisible(true);//設置框架可顯
}

public void btnsub_ActionEvent(ActionEvent e){
String name = txtName.getText();
String pwd = String.valueOf(pwdPwd.getPassword());
if(name.equals("")){
JOptionPane.showMessageDialog(null,"賬號不能為空","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}else if (pwd.equals("")){
JOptionPane.showMessageDialog(null,"密碼不能為空","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}else if(true){
this.dispose();
}else{
JOptionPane.showMessageDialog(null,"賬號或密碼錯誤","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}
}

public void btnreset_ActionEvent(ActionEvent e){
txtName.setText("");
pwdPwd.setText("");
}

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

❺ 如何用java做登錄界面

import javax.swing.JFrame;//框架
import javax.swing.JPanel;//面板
import javax.swing.JButton;//按鈕
import javax.swing.JLabel;//標簽
import javax.swing.JTextField;//文本框
import java.awt.Font;//字體
import java.awt.Color;//顏色
import javax.swing.JPasswordField;//密碼框
import java.awt.event.ActionListener;//事件監聽
import java.awt.event.ActionEvent;//事件處理
import javax.swing.JOptionPane;//消息窗口public class UserLogIn extends JFrame{
public JPanel pnluser;
public JLabel lbluserLogIn;
public JLabel lbluserName;
public JLabel lbluserPWD;
public JTextField txtName;
public JPasswordField pwdPwd;
public JButton btnSub;
public JButton btnReset;

public UserLogIn(){
pnluser = new JPanel();
lbluserLogIn = new JLabel();
lbluserName = new JLabel();
lbluserPWD = new JLabel();
txtName = new JTextField();
pwdPwd = new JPasswordField();
btnSub = new JButton();
btnReset = new JButton();
userInit();
}

public void userInit(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//設置關閉框架的同時結束程序
this.setSize(300,200);//設置框架大小為長300,寬200
this.setResizable(false);//設置框架不可以改變大小
this.setTitle("用戶登錄");//設置框架標題
this.pnluser.setLayout(null);//設置面板布局管理
this.pnluser.setBackground(Color.cyan);//設置面板背景顏色
this.lbluserLogIn.setText("用戶登錄");//設置標簽標題
this.lbluserLogIn.setFont(new Font("宋體",Font.BOLD | Font.ITALIC,14));//設置標簽字體
this.lbluserLogIn.setForeground(Color.RED);//設置標簽字體顏色
this.lbluserName.setText("用戶名:");
this.lbluserPWD.setText("密 碼:");
this.btnSub.setText("登錄");
this.btnReset.setText("重置");
this.lbluserLogIn.setBounds(120,15,60,20);//設置標簽x坐標120,y坐標15,長60,寬20
this.lbluserName.setBounds(50,55,60,20);
this.lbluserPWD.setBounds(50,85,60,25);
this.txtName.setBounds(110,55,120,20);
this.pwdPwd.setBounds(110,85,120,20);
this.btnSub.setBounds(85,120,60,20);
this.btnSub.addActionListener(new ActionListener()//匿名類實現ActionListener介面
{
public void actionPerformed(ActionEvent e){
btnsub_ActionEvent(e);
}
}
);
this.btnReset.setBounds(155,120,60,20);
this.btnReset.addActionListener(new ActionListener()//匿名類實現ActionListener介面
{
public void actionPerformed(ActionEvent e){
btnreset_ActionEvent(e);
}
}
);
this.pnluser.add(lbluserLogIn);//載入標簽到面板
this.pnluser.add(lbluserName);
this.pnluser.add(lbluserPWD);
this.pnluser.add(txtName);
this.pnluser.add(pwdPwd);
this.pnluser.add(btnSub);
this.pnluser.add(btnReset);
this.add(pnluser);//載入面板到框架
this.setVisible(true);//設置框架可顯
}

public void btnsub_ActionEvent(ActionEvent e){
String name = txtName.getText();
String pwd = String.valueOf(pwdPwd.getPassword());
if(name.equals("")){
JOptionPane.showMessageDialog(null,"賬號不能為空","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}else if (pwd.equals("")){
JOptionPane.showMessageDialog(null,"密碼不能為空","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}else if(true){
this.dispose();
}else{
JOptionPane.showMessageDialog(null,"賬號或密碼錯誤","錯誤",JOptionPane.ERROR_MESSAGE);
return;
}
}

public void btnreset_ActionEvent(ActionEvent e){
txtName.setText("");
pwdPwd.setText("");
}

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

❻ 用java程序編寫一個簡單的登錄界面怎麼寫

程序如下:

mport java.awt.HeadlessException;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.ImageIcon;

import javax.swing.JButton;

@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);

btn.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

if ("admin".equal花憨羔窖薏忌割媳公顱s(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製作登錄界面(急)

比較簡單,加幾個組件,再用JDBC連接資料庫就差不多了,自己動手吧,收獲會更多,總拿別人現場代碼不是個事

❽ 用java寫一個登錄界面

是不是用頁面寫啊?

❾ java一個簡單的登錄界面製作


importjava.awt.EventQueue;

importjavax.swing.JFrame;
importjavax.swing.JPanel;
importjavax.swing.border.EmptyBorder;
importjavax.swing.JLabel;
importjava.awt.Font;
importjavax.swing.JTextField;
importjavax.swing.JPasswordField;
importjavax.swing.JButton;
importjava.awt.event.ActionListener;
importjava.awt.event.ActionEvent;

/**
*2014年12月28日下午7:18:41
*@authorseason
*
*/
{

/**
*
*/
=1L;
privateJPanelcontentPane;
privateJTextFieldtextField;
;

/**
*Launchtheapplication.
*/
publicstaticvoidmain(String[]args){
EventQueue.invokeLater(newRunnable(){
publicvoidrun(){
try{
LoginDemoframe=newLoginDemo();
frame.setVisible(true);
}catch(Exceptione){
e.printStackTrace();
}
}
});
}

/**
*Createtheframe.
*/
publicLoginDemo(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,370,300);
contentPane=newJPanel();
contentPane.setBorder(newEmptyBorder(5,5,5,5));
setContentPane(contentPane);
contentPane.setLayout(null);

JLabellblAccount=newJLabel("Account:");
lblAccount.setFont(newFont("Consolas",Font.BOLD,14));
lblAccount.setBounds(25,90,104,28);
contentPane.add(lblAccount);

JLabellblPassword=newJLabel("Password:");
lblPassword.setFont(newFont("Consolas",Font.BOLD,14));
lblPassword.setBounds(25,128,104,28);
contentPane.add(lblPassword);

textField=newJTextField();
textField.setBounds(113,93,154,21);
contentPane.add(textField);
textField.setColumns(10);

passwordField=newJPasswordField();
passwordField.setBounds(113,131,154,21);
contentPane.add(passwordField);


finalJLabellblNewLabel=newJLabel("");
lblNewLabel.setFont(newFont("Consolas",Font.BOLD,12));
lblNewLabel.setBounds(0,222,344,30);
contentPane.add(lblNewLabel);

JButtonbtnSignIn=newJButton("Signin");//登錄按鈕和監聽
btnSignIn.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){

StringuserName=textField.getText();
StringuserPwd=newString(passwordField.getPassword());

if(userName.equals("haiyan")&&userPwd.equals("haiyan")){
lblNewLabel.setText("Yousuccesslogin");


}else{
lblNewLabel.setText("Failtologin,checkplease");
}

}
});
btnSignIn.setFont(newFont("Consolas",Font.BOLD,14));
btnSignIn.setBounds(60,189,93,23);
contentPane.add(btnSignIn);

JButtonbtnReset=newJButton("Reset");//重置按鈕和監聽
btnReset.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
textField.setText("");
passwordField.setText("");

}
});
btnReset.setFont(newFont("Consolas",Font.BOLD,14));
btnReset.setBounds(174,189,93,23);
contentPane.add(btnReset);

JLabellblHaiyan=newJLabel("Haiyan");
lblHaiyan.setFont(newFont("Consolas",Font.BOLD,14));
lblHaiyan.setBounds(123,10,104,28);
contentPane.add(lblHaiyan);

}
}

❿ JAVA製作登錄界面

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>

<style type="text/css">
<!--
body {
background-image: url(_image/22005325164827.jpg);
background-repeat: repeat;
}
-->
</style>
</head>

<body>
<table bgcolor="white" align="center">
<tr>
<td align="center"bgcolor="#808080">==用戶注冊==</td>
</tr>
<tr valign="top">
<td>

<form name="form1" method="post" action="User_Servlet.do" style="background-color: #808080">
<table width="150%" height="555" border="0" cellpadding="0" cellspacing="0" style="background-color: #808080">
<tr>
<td width="11%"></td>
<td width="89%"></td>
</tr>

<tr>
<td align="center">用戶名:</td>
<td><input name="userName" type="text" class="table" id="userName">*</td>
</tr>

<tr>
<td align="center">密碼:</td>
<td class="word"><input name="userPassword" type="password" class="table" id="PWD1">*</td>
</tr>

<tr>
<td align="center">確認密碼:</td>
<td class="word"><input name="userPassword1" type="password" class="table" id="PWD2">*</td>
</tr>

<tr>
<td align="center">生日:</td>
<td class="word"><input name="birthday" type="text" class="table" id="birthday">(格式:1980-07-17)</td>
</tr>

<tr>
<td align="center">性別:</td>
<td><input name="sex" type="radio" value="男" checked>
男生
<input type="radio" name="sex" value="女">
女生</td>
</tr>

<tr>
<td align="center">QQ號:</td>
<td><input name="OICQ" type="text" class="table" id="OICQ"></td>
</tr>

<tr>
<td align="center">電話:</td>
<td><input name="tel" type="text" class="table" id="tel"></td>
</tr>

<tr>
<td align="center">個人主頁:</td>
<td><input name="homepage" type="text" class="table" id="homepage" size="50"></td>
</tr>

<tr>
<td align="center">地址:</td>
<td><input name="address" type="text" class="table" id="address" size="50"></td>
</tr>

<tr>
<td align="center">郵編:</td>
<td><input name="postcode" type="text" class="table" id="postcode"></td>
</tr>

<tr>
<td align="center">Email:</td>
<td class="word"><input name="Email" type="text" class="table" id="Email" size="50">*</td>
</tr>

<script language="javaScript">
function mycheck(){
if(form1.userName.value==""){
alert("請輸入用戶名!");form1.userName.focus();return; }
if(form1.userPassword.value==""){
alert("請輸入密碼!");form1.userPassword.focus();return;}
if(form1.userPassword1.value==""){
alert("請確認密碼!");form1.userPassword1.focus();return;}
if(form1.userPassword.value!=form1.userPassword1.value){
alert("您兩次輸入的密碼不一致,請重新輸入!");
form1.userPassword.value="";form1.userPassword1.value="";form1.userPassword.focus();
return;}
if(form1.Email.value==""){
alert("請輸入Email地址!");form1.Email.focus();return; }
form1.submit();
}
</script>

<tr>
<td colspan="2" align="center"><input type="button" name="save" value="保存" onClick="mycheck()">
<input type="reset" name="reset" value="重置"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>

</body>
<p align="center">LostFruit.com</p>
</html>